Exemplo n.º 1
0
int dlgExtTable::Go(bool modal)
{
    int returncode;
    
    AddGroups(cbOwner);
    AddUsers(cbOwner);

    if (extTable)
    {
        // edit mode

        // TODO:  Make this more like dlgTable, so that it is easier to use.
        // Right now, this is just dummy code until that code is written.
        txtSqlBox->SetText(wxT("(") + extTable->GetSql(NULL).AfterFirst('('));
        oldDefinition = txtSqlBox->GetText();
        txtSqlBox->Enable(false);
    }
    else
    {
        // create mode
    }

     returncode = dlgSecurityProperty::Go(modal);

    // This fixes a UI glitch on MacOS X and Windows
    // Because of the new layout code, the Privileges pane don't size itself properly
    SetSize(GetSize().GetWidth()+1, GetSize().GetHeight());
    SetSize(GetSize().GetWidth()-1, GetSize().GetHeight());

    return returncode;
}
Exemplo n.º 2
0
int dlgSchema::Go(bool modal)
{
    wxString strDefPrivsOnTables, strDefPrivsOnSeqs, strDefPrivsOnFuncs;

    if (!schema)
        cbOwner->Append(wxT(""));

    AddGroups(cbOwner);
    AddUsers(cbOwner);
    if (schema)
    {
        if (connection->BackendMinimumVersion(9, 0))
        {
            strDefPrivsOnTables = schema->GetDefPrivsOnTables();
            strDefPrivsOnSeqs   = schema->GetDefPrivsOnSequences();
            strDefPrivsOnFuncs  = schema->GetDefPrivsOnFunctions();
        }

        // edit mode
        if (!connection->BackendMinimumVersion(7, 5))
            cbOwner->Disable();

        if (schema->GetMetaType() == PGM_CATALOG)
        {
            cbOwner->Disable();
            txtName->Disable();
        }
    }
    else
    {
        // create mode
    }

    return dlgDefaultSecurityProperty::Go(modal, true, strDefPrivsOnTables, strDefPrivsOnSeqs, strDefPrivsOnFuncs);
}
int dlgPackage::Go(bool modal)
{
    if (!connection->EdbMinimumVersion(8, 2))
        txtComment->Disable();

    cbOwner->Disable();

    AddGroups(cbOwner);
    AddUsers(cbOwner);

    if (package)
    {
        // edit mode
        txtName->Disable();

        txtHeader->SetText(package->GetHeaderInner());
        txtBody->SetText(package->GetBodyInner());
    }
    else
    {
        // create mode

    }

    return dlgSecurityProperty::Go(modal);
}
Exemplo n.º 4
0
void CDialogSound::OnBtnDrop()
{
	idStr		classname;
	idStr		key;
	idStr		value;
	idVec3		org;
	idDict		args;
	idAngles	viewAngles;


	gameEdit->PlayerGetViewAngles( viewAngles );
	gameEdit->PlayerGetEyePosition( org );
	org += idAngles( 0, viewAngles.yaw, 0 ).ToForward() * 80 + idVec3( 0, 0, 1 );
	args.Set("origin", org.ToString());
	args.Set("classname", "speaker");
	args.Set("angle", va( "%f", viewAngles.yaw + 180 ));
	args.Set("s_shader", strShader);
	args.Set("s_looping", "1" );
	args.Set("s_shakes", "0" );


	idStr name = gameEdit->GetUniqueEntityName( "speaker" );
	bool nameValid = false;
	while (!nameValid) {
		DialogName dlg("Name Speaker", this);
		dlg.m_strName = name;
		if (dlg.DoModal() == IDOK) {
			idEntity *gameEnt = gameEdit->FindEntity(dlg.m_strName);
			if (gameEnt) {
				if (MessageBox("Please choose another name", "Duplicate Entity Name!", MB_OKCANCEL) == IDCANCEL) {
					return;
				}
			} else {
				nameValid = true;
				name = dlg.m_strName;
			}
		}
	}

	args.Set("name", name.c_str());

	idEntity *ent = NULL;
	gameEdit->SpawnEntityDef( args, &ent );
	if (ent) {
		gameEdit->EntityUpdateChangeableSpawnArgs( ent, NULL );
		gameEdit->ClearEntitySelection();
		gameEdit->AddSelectedEntity( ent );
	}

	gameEdit->MapAddEntity( &args );
	const idDict *dict = gameEdit->MapGetEntityDict( args.GetString( "name" ) );
	Set( dict );
	AddGroups();
	AddSpeakers();
}
Exemplo n.º 5
0
void CDialogSound::ApplyChanges( bool volumeOnly, bool updateInUseTree ) {
	idList<idEntity*> list;
	float vol;

	vol = fVolume;

	list.SetNum( 128 );
	int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
	list.SetNum( count );

	if ( count ) {
		// we might be in either the game or the editor
		idSoundWorld	*sw = soundSystem->GetPlayingSoundWorld();
		if ( sw ) {
			sw->PlayShaderDirectly( "" );
		}

		for (int i = 0; i < count; i++) {
			const idDict *dict = gameEdit->EntityGetSpawnArgs( list[i] );
			if ( dict == NULL ) {
				continue;
			}
			const char *name = dict->GetString( "name" );
			const idDict *dict2 = gameEdit->MapGetEntityDict( name );
			if ( dict2 ) {
				if ( volumeOnly ) {
					float f = dict2->GetFloat( "s_volume" );
					f += vol;
					gameEdit->MapSetEntityKeyVal( name, "s_volume", va( "%f", f ) );
					gameEdit->MapSetEntityKeyVal( name, "s_justVolume", "1" );
					gameEdit->EntityUpdateChangeableSpawnArgs( list[i], dict2 );
					fVolume = f;
					UpdateData( FALSE );
				} else {
					idDict src;
					src.SetFloat( "s_volume", dict2->GetFloat( "s_volume" ));
					Get( &src );
					src.SetBool( "s_justVolume", true );
					gameEdit->MapCopyDictToEntity( name, &src );
					gameEdit->EntityUpdateChangeableSpawnArgs( list[i], dict2 );
					Set( dict2 );
				}
			}
		}
	}

	AddGroups();
	AddSpeakers();
	if ( updateInUseTree ) {
		AddInUseSounds();
	}
}
Exemplo n.º 6
0
BOOL CDialogSound::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Indicate the sound dialog is opened
	com_editors |= EDITOR_SOUND;

	inUseTree = NULL;
	AddSounds(true);
	AddGroups();
	AddSpeakers();
	AddInUseSounds();
	SetWaveSize();

	return TRUE;  // return TRUE unless you set the focus to a control
				  // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 7
0
int dlgSchema::Go(bool modal)
{
	wxString strDefPrivsOnTables, strDefPrivsOnSeqs, strDefPrivsOnFuncs, strDefPrivsOnTypes;

	if (connection->BackendMinimumVersion(9, 1))
	{
		seclabelPage->SetConnection(connection);
		seclabelPage->SetObject(schema);
		this->Connect(EVT_SECLABELPANEL_CHANGE, wxCommandEventHandler(dlgSchema::OnChange));
	}
	else
		seclabelPage->Disable();

	if (!schema)
		cbOwner->Append(wxT(""));

	AddGroups(cbOwner);
	AddUsers(cbOwner);
	if (schema)
	{
		if (connection->BackendMinimumVersion(9, 0))
		{
			strDefPrivsOnTables = schema->GetDefPrivsOnTables();
			strDefPrivsOnSeqs   = schema->GetDefPrivsOnSequences();
			strDefPrivsOnFuncs  = schema->GetDefPrivsOnFunctions();
		}
		if (connection->BackendMinimumVersion(9, 2))
			strDefPrivsOnTypes = schema->GetDefPrivsOnTypes();

		// edit mode
		if (!connection->BackendMinimumVersion(7, 5))
			cbOwner->Disable();

		if (schema->GetMetaType() == PGM_CATALOG)
		{
			cbOwner->Disable();
			txtName->Disable();
		}
	}
	else
	{
		// create mode
	}

	return dlgDefaultSecurityProperty::Go(modal, true, strDefPrivsOnTables, strDefPrivsOnSeqs, strDefPrivsOnFuncs, strDefPrivsOnTypes);
}
Exemplo n.º 8
0
int dlgForeignServer::Go(bool modal)
{
	// Fill owner combobox
	if (!foreignserver)
		cbOwner->Append(wxT(""));
	AddGroups();
	AddUsers(cbOwner);

	// Initialize options listview and buttons
	lstOptions->AddColumn(_("Option"), 80);
	lstOptions->AddColumn(_("Value"), 40);
	txtOption->SetValue(wxT(""));
	txtValue->SetValue(wxT(""));
	btnAdd->Disable();
	btnRemove->Disable();

	if (foreignserver)
	{
		// edit mode
		txtName->Disable();
		txtType->Disable();

		txtType->SetValue(foreignserver->GetType());
		txtVersion->SetValue(foreignserver->GetVersion());

		wxString options = foreignserver->GetOptions();
		wxString option, optionname, optionvalue;
		while (options.Length() > 0)
		{
			option = options.BeforeFirst(',');
			optionname = option.BeforeFirst(wxT('=')).Trim(false).Trim();
			optionvalue = option.AfterFirst(wxT('=')).Trim(false).Trim();
			lstOptions->AppendItem(optionname, optionvalue);
			options = options.AfterFirst(',');
		}
	}
	else
	{
		// create mode
	}

	return dlgSecurityProperty::Go(modal);
}
Exemplo n.º 9
0
BOOL CPropPage_Groups::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();

	int k = m_pSettings->m_GroupList.GetSize();

	CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_LIST_GROUPS);

	CString strResourceBundleString;
	strResourceBundleString.LoadString(IDS_NEWSGROUP);
	pListCtrl->InsertColumn(0, LPCTSTR(strResourceBundleString), LVCFMT_LEFT, 320, -1);

	AddGroups(pListCtrl);

	GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 10
0
void CDialogSound::OnBtnGroup()
{
	idList<idEntity*> list;

	list.SetNum( 128 );
	int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
	list.SetNum( count );

	bool removed = false;
	if (count) {
		for (int i = 0; i < count; i++) {
			const idDict *dict = gameEdit->EntityGetSpawnArgs( list[i] );
			if ( dict == NULL ) {
				continue;
			}
			const char *name = dict->GetString("name");
			dict = gameEdit->MapGetEntityDict( name );
			if ( dict ) {
				if (MessageBox("Are you Sure?", "Delete Selected Speakers", MB_YESNO) == IDYES) {
					gameEdit->MapRemoveEntity( name );
					idEntity *gameEnt = gameEdit->FindEntity( name );
					if ( gameEnt ) {
						gameEdit->EntityStopSound( gameEnt );
						gameEdit->EntityDelete( gameEnt );
						removed = true;
					}
				}
			}
		}
	}

	if (removed) {
		AddGroups();
		AddSpeakers();
	}

}
Exemplo n.º 11
0
void AD::Enumerate(ADSearchFilter searchFilter)
{
    LDAPMessage *search = NULL;
    LDAPMessage *entry = NULL;
    PWCHAR *value;
    PWCHAR attribute;
    berval *ber = NULL;
    DWORD i;
    DWORD j;
    // 20 strings should be enough?
    LPWSTR filters[20];
    BerElement *berElement = NULL;

    // Fill our filters array (NULL-terminated) with search-specific filters.
    switch(searchFilter)
    {
    case AD_SEARCH_USER:
        SetFilter(L"(&(objectClass=user)(objectCategory=person))");
        filters[0] = L"samAccountName";
        filters[1] = L"cn";
        filters[2] = L"homeDirectory";
        filters[3] = L"memberOf";
        filters[4] = NULL;
        break;
    case AD_SEARCH_GROUP:
        SetFilter(L"(&(objectCategory=group))");
        filters[0] = L"samAccountName";
        filters[1] = L"cn";
        filters[2] = L"member";
        filters[3] = NULL;
        break;
    case AD_SEARCH_MACHINE:
        SetFilter(L"(&(objectCategory=computer))");
        filters[0] = L"samAccountName";
        filters[1] = L"cn";
        filters[2] = NULL;
        break;
    default:
        break;
    }

    if(ldap_search_s(ldap, (const PWCHAR)dn.c_str(), LDAP_SCOPE_SUBTREE, (PWCHAR)filter.c_str(), NULL, 0, &search) != LDAP_SUCCESS)
    {
        Util::Error(LdapGetLastError(), L"ldap_search");
        Util::Notice(L"ret = %x\n", LdapGetLastError());
    }

    switch(searchFilter)
    {
    case AD_SEARCH_USER:
        AddUsers(search);
        break;
    case AD_SEARCH_GROUP:
        AddGroups(search);
        break;
    case AD_SEARCH_MACHINE:
        AddServers(search);
        break;
    default:
        break;
    }
    ldap_msgfree(search);
    ber_free(berElement, 0);
}
Exemplo n.º 12
0
void CDialogSound::OnBtnRefreshspeakers()
{
	AddGroups();
	AddSpeakers();
}
int dlgTablespace::Go(bool modal)
{
    if (!tablespace)
        cbOwner->Append(wxEmptyString);
    AddGroups(cbOwner);
    AddUsers(cbOwner);

    pgSet *set;
    if (connection->BackendMinimumVersion(8, 5))
    {
        set=connection->ExecuteSet(wxT("SELECT name, vartype, min_val, max_val\n")
                wxT("  FROM pg_settings WHERE name IN ('seq_page_cost', 'random_page_cost')"));
        if (set)
        {
            while (!set->Eof())
            {
                cbVarname->Append(set->GetVal(0));
                varInfo.Add(set->GetVal(wxT("vartype")) + wxT(" ") + 
                            set->GetVal(wxT("min_val")) + wxT(" ") +
                            set->GetVal(wxT("max_val")));
                set->MoveNext();
            }
            delete set;

            cbVarname->SetSelection(0);
        }
    }
    else
    {
        lstVariables->Enable(false);
        btnAdd->Enable(false);
        btnRemove->Enable(false);
        cbVarname->Enable(false);
        txtValue->Enable(false);
        chkValue->Enable(false);
    }

    if (tablespace)
    {
        // Edit Mode
        txtName->SetValue(tablespace->GetIdentifier());
        txtLocation->SetValue(tablespace->GetLocation());
        txtComment->SetValue(tablespace->GetComment());

        txtLocation->Disable();

        size_t i;
        for (i=0 ; i < tablespace->GetVariables().GetCount() ; i++)
        {
            wxString item=tablespace->GetVariables().Item(i);
            lstVariables->AppendItem(0, item.BeforeFirst('='), item.AfterFirst('='));
        }
    }
    else
    {
    }

    // Tablespace comments are only appropriate in 8.2+
    if (!connection->BackendMinimumVersion(8, 2))
        txtComment->Disable();

    return dlgSecurityProperty::Go(modal);
}
Exemplo n.º 14
0
int dlgForeignDataWrapper::Go(bool modal)
{
	wxString val;

	// Fill owner combobox
	if (!fdw)
		cbOwner->Append(wxEmptyString);
	AddGroups();
	AddUsers(cbOwner);

	if(!connection->BackendMinimumVersion(9, 1))
		cbHandler->Disable();

	// Fill handler combobox
	cbHandler->Append(wxT(""));
	pgSet *set = connection->ExecuteSet(
	                 wxT("SELECT nspname, proname\n")
	                 wxT("  FROM pg_proc p\n")
	                 wxT("  JOIN pg_namespace nsp ON nsp.oid=pronamespace\n")
	                 wxT(" WHERE pronargs=0")
	                 wxT(" AND prorettype=") + NumToStr(PGOID_TYPE_HANDLER));
	if (set)
	{
		while (!set->Eof())
		{
			wxString procname = database->GetSchemaPrefix(set->GetVal(wxT("nspname"))) + set->GetVal(wxT("proname"));
			cbHandler->Append(procname);
			set->MoveNext();
		}
		delete set;
	}
	cbHandler->SetSelection(0);

	// Fill validator combobox
	cbValidator->Append(wxT(""));
	set = connection->ExecuteSet(
	          wxT("SELECT nspname, proname\n")
	          wxT("  FROM pg_proc p\n")
	          wxT("  JOIN pg_namespace nsp ON nsp.oid=pronamespace\n")
	          wxT(" WHERE proargtypes[0]=") + NumToStr(PGOID_TYPE_TEXT_ARRAY) +
	          wxT(" AND proargtypes[1]=") + NumToStr(PGOID_TYPE_OID));
	if (set)
	{
		while (!set->Eof())
		{
			wxString procname = database->GetSchemaPrefix(set->GetVal(wxT("nspname"))) + set->GetVal(wxT("proname"));
			cbValidator->Append(procname);
			set->MoveNext();
		}
		delete set;
	}
	cbValidator->SetSelection(0);

	// Initialize options listview and buttons
	lstOptions->AddColumn(_("Option"), 80);
	lstOptions->AddColumn(_("Value"), 40);
	txtOption->SetValue(wxT(""));
	txtValue->SetValue(wxT(""));
	btnAdd->Disable();
	btnRemove->Disable();

	if (fdw)
	{
		// edit mode
		txtName->Enable(connection->BackendMinimumVersion(9, 2));

		val = fdw->GetHandlerProc();
		if (!val.IsEmpty())
		{
			for (unsigned int i = 0 ; i < cbHandler->GetCount() ; i++)
			{
				if (cbHandler->GetString(i) == val)
					cbHandler->SetSelection(i);
			}
		}

		val = fdw->GetValidatorProc();
		if (!val.IsEmpty())
		{
			for (unsigned int i = 0 ; i < cbValidator->GetCount() ; i++)
			{
				if (cbValidator->GetString(i) == val)
					cbValidator->SetSelection(i);
			}
		}

		wxString options = fdw->GetOptions();
		wxString option, optionname, optionvalue;
		while (options.Length() > 0)
		{
			option = options.BeforeFirst(',');
			optionname = option.BeforeFirst(wxT('=')).Trim(false).Trim();
			optionvalue = option.AfterFirst(wxT('=')).Trim(false).Trim();
			lstOptions->AppendItem(optionname, optionvalue);
			options = options.AfterFirst(',');
		}
	}
	else
	{
		// create mode
	}

	return dlgSecurityProperty::Go(modal);
}
Exemplo n.º 15
0
int dlgFunction::Go(bool modal)
{
	isBackendMinVer84 = connection->BackendMinimumVersion(8, 4);

	if (connection->BackendMinimumVersion(9, 1))
	{
		seclabelPage->SetConnection(connection);
		seclabelPage->SetObject(function);
		this->Connect(EVT_SECLABELPANEL_CHANGE, wxCommandEventHandler(dlgFunction::OnChange));
	}
	else
		seclabelPage->Disable();

	if (function)
	{
		cbSchema->Enable(connection->BackendMinimumVersion(8, 1));
		rdbIn->Disable();
		rdbOut->Disable();
		rdbInOut->Disable();
		rdbVariadic->Disable();
		isProcedure = function->GetIsProcedure();
	}
	else
		cbOwner->Append(wxEmptyString);

	if (!isBackendMinVer84)
		txtArgDefVal->Disable();
	chkLeakProof->Enable(connection->BackendMinimumVersion(9, 2));

	AddGroups(cbOwner);
	AddUsers(cbOwner);

	lstArguments->AddColumn(_("Type"), 60);
	lstArguments->AddColumn(_("Mode"), 40);
	lstArguments->AddColumn(_("Name"), 60);
	lstArguments->AddColumn(_("Default Value"), 60);

	if (!connection->BackendMinimumVersion(8, 0))
		cbOwner->Disable();

	if (!connection->BackendMinimumVersion(8, 3))
		txtCost->Disable();

	txtRows->Disable();

	if (!connection->BackendMinimumVersion(8, 0))
		txtArgName->Disable();

	// Window function can not be modified
	// Disable it for editing
	if (function || !isBackendMinVer84)
		chkWindow->Disable();

	if (isProcedure)
	{
		if (function && !connection->EdbMinimumVersion(8, 2))
			txtName->Disable();
		cbOwner->Disable();
		cbLanguage->Disable();
		chkStrict->Disable();
		chkWindow->Disable();
		chkSecureDefiner->Disable();
		chkSetof->Disable();
		cbVolatility->Disable();
		cbReturntype->Disable();
		txtCost->Disable();
		txtRows->Disable();
		chkLeakProof->Disable();
	}
	else
	{
		if (!connection->BackendMinimumVersion(8, 1))
		{
			rdbIn->SetValue(true);
			rdbIn->Disable();
			rdbOut->Disable();
			rdbInOut->Disable();
		}

		if (!isBackendMinVer84)
		{
			rdbVariadic->Disable();
		}
	}

	pgSet *lang = connection->ExecuteSet(wxT("SELECT lanname FROM pg_language"));
	if (lang)
	{
		while (!lang->Eof())
		{
			wxString language = lang->GetVal(0);
			if (factory == &triggerFunctionFactory)
			{
				if (language.IsSameAs(wxT("SQL"), false) ||
				        language.IsSameAs(wxT("edbspl"), false))
				{
					lang->MoveNext();
					continue;
				}
			}
			cbLanguage->Append(language);
			lang->MoveNext();
		}
		delete lang;
	}

	if (connection->BackendMinimumVersion(8, 3))
	{
		pgSet *set;
		set = connection->ExecuteSet(wxT("SELECT name, vartype, min_val, max_val\n")
		                             wxT("  FROM pg_settings WHERE context in ('user', 'superuser')"));
		if (set)
		{
			while (!set->Eof())
			{
				cbVarname->Append(set->GetVal(0));
				varInfo.Add(set->GetVal(wxT("vartype")) + wxT(" ") +
				            set->GetVal(wxT("min_val")) + wxT(" ") +
				            set->GetVal(wxT("max_val")));
				set->MoveNext();
			}
			delete set;

			cbVarname->SetSelection(0);
			SetupVarEditor(0);
		}

	}
	else
	{
		btnAddVar->Disable();
		btnRemoveVar->Disable();
		cbVarname->Disable();
		txtValue->Disable();
		chkValue->Disable();
	}

	if (function)
	{
		// edit mode

		if (factory != &triggerFunctionFactory)
		{
			wxArrayString argTypes = function->GetArgTypesArray();
			wxArrayString argNames = function->GetArgNamesArray();
			wxArrayString argModes = function->GetArgModesArray();
			wxArrayString argDefs  = function->GetArgDefsArray();

			for (unsigned int i = 0; i < argTypes.Count(); i++)
			{
				if (argModes[i] != wxT("TABLE"))
				{
					if (isBackendMinVer84)
						lstArguments->AppendItem(-1, argTypes.Item(i), argModes[i], argNames[i], (argDefs.Count() > i ? argDefs[i] : wxString(wxEmptyString)));
					else
						lstArguments->AppendItem(-1, argTypes.Item(i), argModes[i], argNames[i]);
				}
			}
		}

		txtArguments->SetValue(function->GetArgListWithNames());
		cbReturntype->Append(function->GetReturnType());
		cbReturntype->SetValue(function->GetReturnType());

		cbLanguage->SetValue(function->GetLanguage());
		cbVolatility->SetValue(function->GetVolatility());

		chkSetof->SetValue(function->GetReturnAsSet());
		chkStrict->SetValue(function->GetIsStrict());
		if (connection->BackendMinimumVersion(8, 4))
			chkWindow->SetValue(function->GetIsWindow());
		chkSecureDefiner->SetValue(function->GetSecureDefiner());
		chkLeakProof->SetValue(function->GetIsLeakProof());

		if (function->GetLanguage().IsSameAs(wxT("C"), false))
		{
			txtObjectFile->SetValue(function->GetBin());
			txtLinkSymbol->SetValue(function->GetSource());
		}
		else
			txtSqlBox->SetText(function->GetSource());

		if (!connection->BackendMinimumVersion(7, 4))
			txtName->Disable();

		if (connection->BackendMinimumVersion(8, 3))
		{
			txtCost->SetValue(NumToStr(function->GetCost()));
			if (function->GetReturnAsSet())
			{
				txtRows->SetValue(NumToStr(function->GetRows()));
				txtRows->Enable();
			}
			else
				txtRows->Disable();
		}

		size_t index;
		for (index = 0 ; index < function->GetConfigList().GetCount() ; index++)
		{
			wxString item = function->GetConfigList().Item(index);
			lstVariables->AppendItem(0, item.BeforeFirst('='), item.AfterFirst('='));
		}

		cbReturntype->Disable();
		chkSetof->Disable();
		cbDatatype->Disable();
		// Editing paramter for wrapped functions is not allowed
		// It will anyway throw an error, if we try to edit the paramter list
		if ( connection->GetIsEdb() &&
		        function->GetSource().Trim(false).StartsWith( wxT( "$__EDBwrapped__$" )))
		{
			isEdbWrapped = true;
			cbDatatype->Disable();
			rdbIn->Disable();
			rdbOut->Disable();
			rdbInOut->Disable();
			rdbVariadic->Disable();
			txtArgName->Disable();
			txtArgDefVal->Disable();
			btnAdd->Disable();
			btnChange->Disable();
			btnRemove->Disable();
		}
	}
	else
	{
		wxString restrict;
		// create mode
		restrict = wxT("(typtype IN ('b', 'c', 'd', 'p') AND typname NOT IN ('any', 'trigger', 'language_handler'))");
		if (!settings->GetShowSystemObjects())
			restrict += wxT(" AND nspname NOT LIKE E'pg\\\\_toast%' AND nspname NOT LIKE E'pg\\\\_temp%'");

		DatatypeReader tr(database, restrict);
		while (tr.HasMore())
		{
			pgDatatype dt = tr.GetDatatype();

			typOids.Add(tr.GetOidStr());
			types.Add(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());

			cbDatatype->Append(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
			if (factory != &triggerFunctionFactory)
				cbReturntype->Append(dt.GetQuotedSchemaPrefix(database) + dt.QuotedFullName());
			tr.MoveNext();
		}

		long sel;
		if (factory == &triggerFunctionFactory)
		{
			cbReturntype->Append(wxT("trigger"));
			cbReturntype->SetSelection(0);
			cbReturntype->Disable();
			lstArguments->Disable();
			cbDatatype->Disable();
			txtArgName->Disable();
			sel = cbLanguage->FindString(wxT("c"));
		}
		else if (isProcedure)
			sel = cbLanguage->FindString(wxT("edbspl"));
		else
			sel = cbLanguage->FindString(wxT("sql"));

		if (sel >= 0)
			cbLanguage->SetSelection(sel);
		txtObjectFile->SetValue(TXTOBJ_LIB);
	}

	wxNotifyEvent event;
	OnSelChangeLanguage(event);

	return dlgSecurityProperty::Go(modal);
}
Exemplo n.º 16
0
int dlgForeignTable::Go(bool modal)
{
	seclabelPage->SetConnection(connection);
	seclabelPage->SetObject(foreigntable);
	this->Connect(EVT_SECLABELPANEL_CHANGE, wxCommandEventHandler(dlgForeignTable::OnChange));

	// Fill owner combobox
	if (!foreigntable)
		cbOwner->Append(wxT(""));
	AddGroups();
	AddUsers(cbOwner);

	// Fill datatype combobox
	FillDatatype(cbDatatype);

	// Initialize options listview and buttons
	lstOptions->AddColumn(_("Option"), 80);
	lstOptions->AddColumn(_("Value"), 40);
	txtOption->SetValue(wxT(""));
	txtValue->SetValue(wxT(""));
	btnAdd->Disable();
	btnRemove->Disable();

	if (foreigntable)
	{
		// Edit Mode
		cbForeignServer->SetValue(foreigntable->GetForeignServer());
		cbForeignServer->Disable();

		txtMembername->Enable(true);
		btnAddMember->Enable(true);
		btnChangeMember->Enable(false);
		btnRemoveMember->Enable(false);

		wxArrayString elements = foreigntable->GetTypesArray();
		wxString fullType, typeName, typeLength, typePrecision;
		size_t pos;
		size_t i;
		for (i = 0 ; i < elements.GetCount() ; i += 3)
		{
			lstMembers->AppendItem(0, elements.Item(i), elements.Item(i + 1), elements.Item(i + 2));

			fullType = elements.Item(i + 1);
			typeName = fullType;
			typeLength = wxEmptyString;
			typePrecision = wxEmptyString;

			if (fullType.Find(wxT("(")) > 0)
			{
				// there is at least a length
				typeName = fullType.BeforeFirst('(');
				if (fullType.Find(wxT(",")) > 0)
				{
					// there is also a precision
					typeLength = fullType.AfterFirst('(').BeforeFirst(',');
					typePrecision = fullType.AfterFirst(',').BeforeFirst(')');
				}
				else
					typeLength = fullType.AfterFirst('(').BeforeFirst(')');
			}

			for (pos = 0; pos < cbDatatype->GetCount() - 1; pos++)
			{
				if (cbDatatype->GetString(pos) == typeName)
				{
					memberTypes.Add(GetTypeInfo(pos));
					break;
				}
			}
			memberLengths.Add(typeLength);
			memberPrecisions.Add(typePrecision);
			memberNotNulls.Add(elements.Item(i + 2));
		}

		cbDatatype->Enable();
		txtLength->Enable();

		wxArrayString options = foreigntable->GetOptionsArray();
		wxString optionname, optionvalue;
		for (unsigned int index = 0; index < options.Count(); index += 2)
		{
			optionname = options.Item(index);
			optionvalue = options.Item(index + 1);
			lstOptions->AppendItem(optionname, optionvalue);
		}
	}
	else
	{
		// Create mode
		cbOwner->Append(wxEmptyString);
		cbOwner->Disable();

		pgSet *set = connection->ExecuteSet(
		                 wxT("SELECT srvname\n")
		                 wxT("  FROM pg_foreign_server\n")
		                 wxT("  ORDER BY srvname"));
		if (set)
		{
			while (!set->Eof())
			{
				wxString srvname = set->GetVal(wxT("srvname"));
				cbForeignServer->Append(srvname);
				set->MoveNext();
			}
			delete set;
		}
		cbForeignServer->SetSelection(0);
	}

	txtLength->SetValidator(numericValidator);

	return dlgTypeProperty::Go(modal);
}