Exemplo n.º 1
0
// Returns the amount if the component parameter is specified. If the component parameter is nil
// it returns the definition of the component for the given index.
global func GetComponent(id component, int index)
{
	// Safety: can only be called from object or definition context.
	if (!this || (GetType(this) != C4V_C4Object && GetType(this) != C4V_Def))
		return FatalError(Format("GetComponent must be called from object or definition context and not from %v", this));

	// Safety: return nil if Components could not be found or are not a proplist.
	if (!this.Components || GetType(this.Components) != C4V_PropList)
		return;
		
	// If component is specified return the count for that definition.
	if (GetType(component) == C4V_Def)
		return this.Components[Format("%i", component)];

	// Ensure the index is valid.	
	index = Max(index, 0);

	// If component is not specified return the definition of the component at the index.
	var cnt = 0;
	for (var entry in GetProperties(this.Components))
	{
		// Check if the entry is an actual valid definition.
		var entry_def = GetDefinition(entry);
		if (!entry_def)
			continue;
		if (index == cnt)
			return entry_def;
		cnt++;
	}
	return;
}
Exemplo n.º 2
0
wxString dlgCheck::GetSql()
{
	wxString sql;
	wxString name = GetName();

	if (!check)
	{
		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
		      + wxT("\n  ADD");
		AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
		sql += wxT("\n  CHECK ") + GetDefinition()
		       + wxT(";\n");
	}
	else
	{
		if (check->GetName() != name)
		{
			sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
			      + wxT("\n  RENAME CONSTRAINT ") + qtIdent(check->GetName())
			      + wxT(" TO ") + qtIdent(name) + wxT(";\n");
		}
		if (connection->BackendMinimumVersion(9, 2) && !check->GetValid() && !chkDontValidate->GetValue())
		{
			sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
			       + wxT("\n  VALIDATE CONSTRAINT ") + qtIdent(name) + wxT(";\n");
		}
	}

	if (!name.IsEmpty())
		AppendComment(sql, wxT("CONSTRAINT ") + qtIdent(name)
		              + wxT(" ON ") + table->GetQuotedFullIdentifier(), check);
	return sql;
}
Exemplo n.º 3
0
wxString pgForeignKey::GetConstraint()
{
	wxString sql;
	sql = GetQuotedIdentifier()
	      +  wxT(" FOREIGN KEY ") + GetDefinition();

	return sql;
}
Exemplo n.º 4
0
func GiveAllKnowledge()
{
	var i, id;
	while (id = GetDefinition(i++))
	{
		SetPlrKnowledge(nil, id);
	}
}
Exemplo n.º 5
0
void pgView::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;
		browser->RemoveDummyChild(this);

		browser->AppendCollection(this, columnFactory);

		pgCollection *collection = browser->AppendCollection(this, ruleFactory);
		collection->iSetOid(GetOid());
		collection->ShowTreeDetail(browser);
		treeObjectIterator colIt(browser, collection);

		pgRule *rule;
		while (!hasInsertRule && !hasUpdateRule && !hasDeleteRule && (rule = (pgRule *)colIt.GetNextObject()) != 0)
		{
			if (rule->GetEvent().Find(wxT("INSERT")) >= 0)
				hasInsertRule = true;
			if (rule->GetEvent().Find(wxT("UPDATE")) >= 0)
				hasUpdateRule = true;
			if (rule->GetEvent().Find(wxT("DELETE")) >= 0)
				hasDeleteRule = true;
		}

		if (GetConnection()->BackendMinimumVersion(9, 1))
			browser->AppendCollection(this, triggerFactory);
	}
	if (properties)
	{
		CreateListColumns(properties);
		wxString def = GetDefinition().Left(250);
		def.Replace(wxT("\n"), wxT(" "));

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Definition"), def);
		properties->AppendYesNoItem(_("System view?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
		if (GetConnection()->BackendMinimumVersion(9, 2) && GetSecurityBarrier().Length() > 0)
			properties->AppendItem(_("Security barrier?"), GetSecurityBarrier());

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}
Exemplo n.º 6
0
std::string CSpaceWarItem::GetIconURL() const
{
	std::string ret;
	char buf[512];
	uint32 bufSize = sizeof(buf);
	if ( SteamInventory()->GetItemDefinitionProperty( GetDefinition(), "icon_url", buf, &bufSize ) && bufSize <= sizeof(buf) )
	{
		ret = buf;
	}
	return ret;
}
Exemplo n.º 7
0
std::string CSpaceWarItem::GetLocalizedDescription() const
{
	std::string ret;
	char buf[2048];
	uint32 bufSize = sizeof(buf);
	if ( SteamInventory()->GetItemDefinitionProperty( GetDefinition(), "description", buf, &bufSize ) && bufSize <= sizeof(buf) )
	{
		ret = buf;
	}
	return ret;
}
Exemplo n.º 8
0
Flow::Components::Constant<T>::Constant(TypeManager const &type_manager,
                                        std::string instance_name,
                                        ComponentInputConnectionPtrsDict input_connection_ptrs_dict,
                                        InstanceData instance_data)
    : Component(type_manager,
                GetDefinition(),
                ComponentInstance{std::move(instance_name),
                                  std::move(input_connection_ptrs_dict),
                                  {{"Value", &m_Value}}})
    , m_Value(std::move(instance_data.Value()))
{
}
Exemplo n.º 9
0
wxString dlgForeignKey::GetSql()
{
	wxString sql;
	wxString name = GetName();

	if (!foreignKey)
	{
		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
		      + wxT("\n  ADD");
		AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
		sql += wxT(" FOREIGN KEY ") + GetDefinition()
		       + wxT(";\n");
	}
	else
	{
		if (foreignKey->GetName() != name)
		{
			sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
			      + wxT("\n  RENAME CONSTRAINT ") + qtIdent(foreignKey->GetName())
			      + wxT(" TO ") + qtIdent(name) + wxT(";\n");
		}
		if (connection->BackendMinimumVersion(9, 1) && !foreignKey->GetValid() && !chkDontValidate->GetValue())
		{
			sql += wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
			       + wxT("\n  VALIDATE CONSTRAINT ") + qtIdent(name) + wxT(";\n");
		}
	}

	if (!name.IsEmpty())
		AppendComment(sql, wxT("CONSTRAINT ") + qtIdent(name)
		              + wxT(" ON ") + table->GetQuotedFullIdentifier(), foreignKey);

	if (chkAutoIndex->GetValue())
	{
		sql += wxT("CREATE INDEX ") + qtIdent(txtIndexName->GetValue())
		       +  wxT("\n  ON ") + table->GetQuotedFullIdentifier()
		       +  wxT("(");

		int pos;
		for (pos = 0 ; pos < lstColumns->GetItemCount() ; pos++)
		{
			if (pos)
				sql += wxT(", ");

			sql += qtIdent(lstColumns->GetText(pos));
		}

		sql += wxT(");\n");
	}
	return sql;
}
Exemplo n.º 10
0
wxString pgCheck::GetConstraint()
{
	sql = GetQuotedIdentifier() +  wxT(" CHECK ");

	sql += wxT("(") + GetDefinition() + wxT(")");

	if (GetDatabase()->BackendMinimumVersion(9, 2) && GetNoInherit())
		sql += wxT(" NO INHERIT");

	if (GetDatabase()->BackendMinimumVersion(9, 2) && !GetValid())
		sql += wxT(" NOT VALID");

	return sql;
}
Exemplo n.º 11
0
std::string CSpaceWarItem::GetLocalizedName() const
{
	std::string ret;
	char buf[512];
	uint32 bufSize = sizeof(buf);
	if ( SteamInventory()->GetItemDefinitionProperty( GetDefinition(), "name", buf, &bufSize ) && bufSize <= sizeof(buf) )
	{
		ret = buf;
	}
	else
	{
		ret = "(unknown)";
	}
	return ret;
}
Exemplo n.º 12
0
	void Dictionary::SaveAsJSON()
	{
		FILE *f;
		if(fopen_s(&f, "C:\\Users\\chs\\dictionary.json", "w") == 0)
		{
			fputs("Dictionary = {\n", f);
			for(uint i=0; i<mNumWords; ++i)
			{
				char *p = Dictionary::mWord + i * 8;
				string s = GetDefinition(i, "", "\\n");
				find_and_replace(s, "\"", "'");
				fprintf_s(f, "\t\"%s\": \"%s\"%s\n", p, s.c_str(), (i < mNumWords - 1) ? "," : "");
			}
			fputs("}\n", f);
			fclose(f);
		}
	}
Exemplo n.º 13
0
// Iterates over the properties defined on the element.
bool ElementStyle::IterateProperties(int& index, PseudoClassList& property_pseudo_classes, String& name, const Property*& property)
{
	// First check for locally defined properties.
	if (local_properties != NULL)
	{
		if (index < local_properties->GetNumProperties())
		{
			PropertyMap::const_iterator i = local_properties->GetProperties().begin();
			for (int count = 0; count < index; ++count)
				++i;

			name = (*i).first;
			property = &((*i).second);
			property_pseudo_classes.clear();
			++index;

			return true;
		}
	}

	const ElementDefinition* definition = GetDefinition();
	if (definition != NULL)
	{
		int index_offset = 0;
		if (local_properties != NULL)
			index_offset = local_properties->GetNumProperties();

		// Offset the index to be relative to the definition before we start indexing. When we do get a property back,
		// check that it hasn't been overridden by the element's local properties; if so, continue on to the next one.
		index -= index_offset;
		while (definition->IterateProperties(index, pseudo_classes, property_pseudo_classes, name, property))
		{
			if (local_properties == NULL ||
				local_properties->GetProperty(name) == NULL)
			{
				index += index_offset;
				return true;
			}
		}

		return false;
	}

	return false;
}
Exemplo n.º 14
0
global func ActivateMedalRule()
{
	var medal_rule_def = GetDefinition("Rule_Medals");
	if (medal_rule_def)
	{
		var medal_rule = CreateObject(medal_rule_def);
		if (!medal_rule)
			return false;
		// Do logging of medals in normal log.
		medal_rule->SetLogging(true);
		// No clunker rewards.
		medal_rule->SetRewarding(false);
		// Create the medal rewards object instead which gives mana.
		CreateObject(Env_MedalRewards);
		return true;
	}
	return false;
}
Exemplo n.º 15
0
// Returns the definition or nil if par is a string and the definition exists.
// See the documentation for the case when par is an integer.
global func GetDefinition(par)
{
	// Overload behavior when par is a string.
	if (GetType(par) == C4V_String)
	{
		if (GetDefinition_Loaded_Definition_List == nil)
		{
			// Fill the static list of definitions when it has not been generated yet.
			GetDefinition_Loaded_Definition_List = {};
			var i = 0, def;
			while (def = GetDefinition(i++))
				GetDefinition_Loaded_Definition_List[Format("%i", def)] = def;
		}
		// Return the definition if in the list and nil otherwise.
		return GetDefinition_Loaded_Definition_List[par];
	}
	return _inherited(par, ...);
}
Exemplo n.º 16
0
EntityPtr EntityPalette::Create( std::string type, std::string id )
{
	EntityDefPtr def = GetDefinition(type);
	if (!def)
		return EntityPtr();

	Body* body;
	if (def->GetBodyDefinition()->Type == BodyDef::SimpleBody)
	{ 
		body = new SimpleBody();
	}
	else if (def->GetBodyDefinition()->Type == BodyDef::Box2DBody)
	{
		body = new Box2DBody(def->GetBodyDefinition());
	}

	GraphicsPtr graphics	= def->GetGraphicsDefinition()->Create();
	BehaviourPtr behaviour	= def->GetBehaviourDefinition()->Create();

	EntityPtr entity(new Entity());
	entity->mGraphics = graphics;
	entity->mBehaviour = behaviour;
	entity->mBody = body;

	graphics->mEntity = entity;
	behaviour->mActor = entity;
	body->SetEntity(entity.get());

	if (id == "")
	{
		std::string prefix = "GameObject_";
		int n = 0;
		while (mEntites.find(prefix + itoa(n, 16)) != mEntites.end())
			++n;
		id = prefix + itoa(n, 16);
	}

	entity->mName = id;
	entity->mType = def->GetType();

	mEntites[id] = entity;

	return entity;
}
Exemplo n.º 17
0
void pgView::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;
		browser->RemoveDummyChild(this);

		browser->AppendCollection(this, columnFactory);

		pgCollection *collection = browser->AppendCollection(this, ruleFactory);
		collection->iSetOid(GetOid());
		collection->ShowTreeDetail(browser);
		treeObjectIterator colIt(browser, collection);

		pgRule *rule;
		while (!hasInsertRule && !hasUpdateRule && !hasDeleteRule && (rule = (pgRule *)colIt.GetNextObject()) != 0)
		{
			if (rule->GetEvent().Find(wxT("INSERT")) >= 0)
				hasInsertRule = true;
			if (rule->GetEvent().Find(wxT("UPDATE")) >= 0)
				hasUpdateRule = true;
			if (rule->GetEvent().Find(wxT("DELETE")) >= 0)
				hasDeleteRule = true;
		}

		if (GetConnection()->BackendMinimumVersion(9, 1))
			browser->AppendCollection(this, triggerFactory);
	}
	if (properties)
	{
		CreateListColumns(properties);
		wxString def = GetDefinition().Left(250);
		def.Replace(wxT("\n"), wxT(" "));

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Definition"), def);
		properties->AppendYesNoItem(_("System view?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
	}
}
Exemplo n.º 18
0
void pgCheck::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Definition"), GetDefinition());
		if (GetDatabase()->BackendMinimumVersion(9, 2))
		{
			properties->AppendItem(_("No Inherit?"), BoolToYesNo(GetNoInherit()));
			properties->AppendItem(_("Valid?"), BoolToYesNo(GetValid()));
		}
		// Check constraints on a domain don't have comments
		if (objectKind.Upper() == wxT("TABLE"))
			properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
	}
}
Exemplo n.º 19
0
    bool ModelComponent::SetMaterial(size_t materialIndex, const char* materialRelativePath)
    {
        if (this->model != nullptr)
        {
            auto oldMaterial = this->model->meshes[materialIndex]->GetMaterial();
            if (oldMaterial != nullptr && oldMaterial->GetDefinition().relativePath == materialRelativePath)
            {
                return true;
            }

            if (this->model->meshes[materialIndex]->SetMaterial(materialRelativePath))
            {
                this->OnChanged(ChangeFlag_Material);
                return true;
            }
        }

        return false;
    }
Exemplo n.º 20
0
wxString dlgCheck::GetSql()
{
    wxString sql;
    wxString name = GetName();

    if (!check)
    {
        sql = wxT("ALTER ") + object->GetTypeName().Upper() + wxT(" ") + object->GetQuotedFullIdentifier()
              + wxT("\n  ADD");
        if (name.Length() > 0)
        {
            sql += wxT(" CONSTRAINT ") + qtIdent(name) + wxT("\n ");
        }
        sql += wxT(" CHECK ");
        sql += GetDefinition();
        if (connection->BackendMinimumVersion(9, 2) && chkNoInherit->GetValue())
        {
            sql += wxT(" NO INHERIT");
        }
        sql += wxT(";\n");
    }
    else
    {
        if (check->GetName() != name)
        {
            sql = wxT("ALTER ") + object->GetTypeName().Upper() + wxT(" ") + object->GetQuotedFullIdentifier()
                  + wxT("\n  RENAME CONSTRAINT ") + qtIdent(check->GetName())
                  + wxT(" TO ") + qtIdent(name) + wxT(";\n");
        }
        if (connection->BackendMinimumVersion(9, 2) && !check->GetValid() && !chkDontValidate->GetValue())
        {
            sql += wxT("ALTER ") + object->GetTypeName().Upper() + wxT(" ") + object->GetQuotedFullIdentifier()
                   + wxT("\n  VALIDATE CONSTRAINT ") + qtIdent(name) + wxT(";\n");
        }
    }

    if (!name.IsEmpty())
        AppendComment(sql, wxT("CONSTRAINT ") + qtIdent(name)
                      + wxT(" ON ") + object->GetQuotedFullIdentifier(), check);
    return sql;
}
Exemplo n.º 21
0
wxString dlgIndexConstraint::GetSql()
{
	wxString sql;
	wxString name = GetName();

	if (!index)
	{
		sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
		      + wxT("\n  ADD");
		AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));

		sql += wxT(" ") + wxString(factory->GetTypeName()).Upper() + wxT(" ") + GetDefinition()
		       + wxT(";\n");
	}
	else
	{
		if (connection->BackendMinimumVersion(8, 0) && cbTablespace->GetOIDKey() != index->GetTablespaceOid())
		{
			sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
			       +  wxT("\n  SET TABLESPACE ") + qtIdent(cbTablespace->GetValue())
			       + wxT(";\n");
		}

		if (txtFillFactor->GetValue().Trim().Length() > 0 && txtFillFactor->GetValue() != index->GetFillFactor())
		{
			sql += wxT("ALTER INDEX ") + index->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(name)
			       +  wxT("\n  SET (FILLFACTOR=")
			       +  txtFillFactor->GetValue() + wxT(");\n");
		}
	}

	if (!name.IsEmpty())
		AppendComment(sql, wxT("CONSTRAINT ") + qtIdent(name)
		              + wxT(" ON ") + table->GetQuotedFullIdentifier(), index);

	return sql;
}
Exemplo n.º 22
0
wxString dlgForeignKey::GetSql()
{
    wxString sql;
    wxString name=GetName();

    if (!foreignKey)
    {
        sql = wxT("ALTER TABLE ") + table->GetQuotedFullIdentifier()
            + wxT(" ADD");
        AppendIfFilled(sql, wxT(" CONSTRAINT "), qtIdent(name));
        sql +=wxT(" FOREIGN KEY ") + GetDefinition()
            + wxT(";\n");
    }
    if (!name.IsEmpty())
        AppendComment(sql, wxT("CONSTRAINT ") + qtIdent(name) 
            + wxT(" ON ") + table->GetQuotedFullIdentifier(), foreignKey);

    if (chkAutoIndex->GetValue())
    {
        sql += wxT("CREATE INDEX ") + qtIdent(txtIndexName->GetValue())
            +  wxT(" ON ") + table->GetQuotedFullIdentifier()
            +  wxT("(");

        int pos;
        for (pos=0 ; pos < lstColumns->GetItemCount() ; pos++)
        {
            if (pos)
                sql += wxT(", ");

            sql += qtIdent(lstColumns->GetText(pos));
        }

        sql += wxT(");\n");
    }
    return sql;
}
Exemplo n.º 23
0
void pgView::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;
		browser->RemoveDummyChild(this);

		browser->AppendCollection(this, columnFactory);

		pgCollection *collection = browser->AppendCollection(this, ruleFactory);
		collection->iSetOid(GetOid());
		collection->ShowTreeDetail(browser);
		treeObjectIterator colIt(browser, collection);

		pgRule *rule;
		while (!hasInsertRule && !hasUpdateRule && !hasDeleteRule && (rule = (pgRule *)colIt.GetNextObject()) != 0)
		{
			if (rule->GetEvent().Find(wxT("INSERT")) >= 0)
				hasInsertRule = true;
			if (rule->GetEvent().Find(wxT("UPDATE")) >= 0)
				hasUpdateRule = true;
			if (rule->GetEvent().Find(wxT("DELETE")) >= 0)
				hasDeleteRule = true;
		}

		if (GetConnection()->BackendMinimumVersion(9, 1))
			browser->AppendCollection(this, triggerFactory);
	}
	if (properties)
	{
		CreateListColumns(properties);
		wxString def = GetDefinition().Left(250);
		def.Replace(wxT("\n"), wxT(" "));

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Definition"), def);
		properties->AppendYesNoItem(_("System view?"), GetSystemObject());
		if (GetConnection()->BackendMinimumVersion(9, 2) && GetSecurityBarrier().Length() > 0)
			properties->AppendItem(_("Security barrier?"), GetSecurityBarrier());

		if (GetConnection()->BackendMinimumVersion(9, 3))
			properties->AppendYesNoItem(_("Materialized view?"), GetMaterializedView());

		/* Custom AutoVacuum Settings */
		if (GetConnection()->BackendMinimumVersion(9, 3) && GetMaterializedView())
		{
			if (!GetFillFactor().IsEmpty())
				properties->AppendItem(_("Fill factor"), GetFillFactor());

			if (GetCustomAutoVacuumEnabled())
			{
				if (GetAutoVacuumEnabled() != 2)
				{
					properties->AppendItem(_("Table auto-vacuum enabled?"), GetAutoVacuumEnabled() == 1 ? _("Yes") : _("No"));
				}
				if (!GetAutoVacuumVacuumThreshold().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum VACUUM base threshold"), GetAutoVacuumVacuumThreshold());
				if (!GetAutoVacuumVacuumScaleFactor().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum VACUUM scale factor"), GetAutoVacuumVacuumScaleFactor());
				if (!GetAutoVacuumAnalyzeThreshold().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum ANALYZE base threshold"), GetAutoVacuumAnalyzeThreshold());
				if (!GetAutoVacuumAnalyzeScaleFactor().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum ANALYZE scale factor"), GetAutoVacuumAnalyzeScaleFactor());
				if (!GetAutoVacuumVacuumCostDelay().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum VACUUM cost delay"), GetAutoVacuumVacuumCostDelay());
				if (!GetAutoVacuumVacuumCostLimit().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum VACUUM cost limit"), GetAutoVacuumVacuumCostLimit());
				if (!GetAutoVacuumFreezeMinAge().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum FREEZE minimum age"), GetAutoVacuumFreezeMinAge());
				if (!GetAutoVacuumFreezeMaxAge().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum FREEZE maximum age"), GetAutoVacuumFreezeMaxAge());
				if (!GetAutoVacuumFreezeTableAge().IsEmpty())
					properties->AppendItem(_("Table auto-vacuum FREEZE table age"), GetAutoVacuumFreezeTableAge());
			}

			if (GetHasToastTable() && GetToastCustomAutoVacuumEnabled())
			{
				if (GetToastAutoVacuumEnabled() != 2)
				{
					properties->AppendItem(_("Toast auto-vacuum enabled?"), GetToastAutoVacuumEnabled() == 1 ? _("Yes") : _("No"));
				}
				if (!GetToastAutoVacuumVacuumThreshold().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum VACUUM base threshold"), GetToastAutoVacuumVacuumThreshold());
				if (!GetToastAutoVacuumVacuumScaleFactor().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum VACUUM scale factor"), GetToastAutoVacuumVacuumScaleFactor());
				if (!GetToastAutoVacuumVacuumCostDelay().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum VACUUM cost delay"), GetToastAutoVacuumVacuumCostDelay());
				if (!GetToastAutoVacuumVacuumCostLimit().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum VACUUM cost limit"), GetToastAutoVacuumVacuumCostLimit());
				if (!GetToastAutoVacuumFreezeMinAge().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum FREEZE minimum age"), GetToastAutoVacuumFreezeMinAge());
				if (!GetToastAutoVacuumFreezeMaxAge().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum FREEZE maximum age"), GetToastAutoVacuumFreezeMaxAge());
				if (!GetToastAutoVacuumFreezeTableAge().IsEmpty())
					properties->AppendItem(_("Toast auto-vacuum FREEZE table age"), GetToastAutoVacuumFreezeTableAge());
			}

			properties->AppendItem(_("Tablespace"), tablespace);

			if (GetIsPopulated().Cmp(wxT("t")) == 0)
				properties->AppendItem(_("With data?"), _("Yes"));
			else
				properties->AppendItem(_("With data?"), _("No"));
		}

		if (GetConnection()->BackendMinimumVersion(9, 4))
			properties->AppendItem(_("Check Option"), GetCheckOption());

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}

		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
	}
}
Exemplo n.º 24
0
int dlgColumn::Go(bool modal)
{
	if (connection->BackendMinimumVersion(8, 4))
	{
		securityPage->SetConnection(connection);

		if (securityPage->cbGroups)
		{
			// Fetch Groups Information
			for ( unsigned int index = 0; index < groups.Count();)
				securityPage->cbGroups->Append(wxT("group ") + groups[index++]);

			// Fetch Users Information
			if (settings->GetShowUsersForPrivileges())
			{
				securityPage->stGroup->SetLabel(_("Group/User"));
				dlgProperty::AddUsers(securityPage->cbGroups);
				Layout();
			}
		}
		securityPage->lbPrivileges->GetParent()->Layout();
	}

	if (connection->BackendMinimumVersion(8, 5))
	{
		cbVarname->Append(wxT("n_distinct"));
		cbVarname->Append(wxT("n_distinct_inherited"));
		cbVarname->SetSelection(0);
	}
	else
	{
		lstVariables->Enable(false);
		btnAdd->Enable(false);
		btnRemove->Enable(false);
		cbVarname->Enable(false);
		txtValue->Enable(false);
	}

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

	cbStorage->Enable(true);

	if (connection->BackendMinimumVersion(9, 1))
	{
		// fill collation combobox
		cbCollation->Append(wxEmptyString);
		pgSet *set = connection->ExecuteSet(
		                 wxT("SELECT nspname, collname\n")
		                 wxT("  FROM pg_collation c, pg_namespace n\n")
		                 wxT("  WHERE c.collnamespace=n.oid\n")
		                 wxT("  ORDER BY nspname, collname"));
		if (set)
		{
			while (!set->Eof())
			{
				wxString name = qtIdent(set->GetVal(wxT("nspname"))) + wxT(".") + qtIdent(set->GetVal(wxT("collname")));
				cbCollation->Append(name);
				set->MoveNext();
			}
			delete set;
		}
		cbCollation->SetSelection(0);
	}
	else
		cbCollation->Disable();

	if (column)
	{
		// edit mode
		if (column->GetLength() > 0)
			txtLength->SetValue(NumToStr(column->GetLength()));
		if (column->GetPrecision() >= 0)
			txtPrecision->SetValue(NumToStr(column->GetPrecision()));
		txtDefault->SetValue(column->GetDefault());
		chkNotNull->SetValue(column->GetNotNull());
		txtAttstattarget->SetValue(NumToStr(column->GetAttstattarget()));

		wxString fullType = column->GetRawTypename();
		if (column->GetIsArray())
			fullType += wxT("[]");
		cbDatatype->Append(fullType);
		AddType(wxT("?"), column->GetAttTypId(), fullType);

		if (!column->IsReferenced())
		{
			wxString typeSql =
			    wxT("SELECT tt.oid, format_type(tt.oid,NULL) AS typname\n")
			    wxT("  FROM pg_cast\n")
			    wxT("  JOIN pg_type tt ON tt.oid=casttarget\n")
			    wxT(" WHERE castsource=") + NumToStr(column->GetAttTypId()) + wxT("\n");

			if (connection->BackendMinimumVersion(8, 0))
				typeSql += wxT("   AND castcontext IN ('i', 'a')");
			else
				typeSql += wxT("   AND castfunc=0");

			pgSetIterator set(connection, typeSql);

			while (set.RowsLeft())
			{
				if (set.GetVal(wxT("typname")) != column->GetRawTypename())
				{
					cbDatatype->Append(set.GetVal(wxT("typname")));
					AddType(wxT("?"), set.GetOid(wxT("oid")), set.GetVal(wxT("typname")));
				}
			}
		}
		if (cbDatatype->GetCount() <= 1)
			cbDatatype->Disable();

		cbDatatype->SetSelection(0);
		wxNotifyEvent ev;
		OnSelChangeTyp(ev);

		previousDefinition = GetDefinition();
		if (column->GetColNumber() < 0)  // Disable controls not valid for system columns
		{
			txtName->Disable();
			txtDefault->Disable();
			chkNotNull->Disable();
			txtLength->Disable();
			cbDatatype->Disable();
			txtAttstattarget->Disable();
			cbStorage->Disable();
			cbCollation->Disable();
		}
		else if (column->GetTable()->GetMetaType() == PGM_VIEW) // Disable controls not valid for view columns
		{
			txtName->Disable();
			chkNotNull->Disable();
			txtLength->Disable();
			cbDatatype->Disable();
			txtAttstattarget->Disable();
			cbStorage->Disable();
			cbCollation->Disable();
		}
		else if (column->GetTable()->GetMetaType() == GP_EXTTABLE) // Disable controls not valid for external table columns
		{
			txtName->Disable();
			chkNotNull->Disable();
			txtLength->Disable();
			cbDatatype->Disable();
			txtAttstattarget->Disable();
			txtDefault->Disable();
			cbStorage->Disable();
			cbCollation->Disable();
		}
		else if (table->GetOfTypeOid() > 0)
		{
			txtName->Disable();
			chkNotNull->Enable();
			txtLength->Disable();
			cbDatatype->Disable();
			txtAttstattarget->Enable();
			txtDefault->Enable();
			cbStorage->Enable();
			cbCollation->Disable();
		}

		cbStorage->SetValue(column->GetStorage());
		cbCollation->SetValue(column->GetCollation());

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

	}
	else
	{
		// create mode
		FillDatatype(cbDatatype, true, true);

		if (!table)
		{
			cbClusterSet->Disable();
			cbClusterSet = 0;
		}

		txtAttstattarget->Disable();
		cbStorage->Disable();
	}

	if (changedColumn)
		ApplyChangesToDlg();

	return dlgTypeProperty::Go(modal);
}
Exemplo n.º 25
0
/*static*/ Flow::TypeManagerComponentTypeEntry Flow::Components::Constant<T>::GetComponentTypeEntry()
{
    return {GetDefinition(), MakeInstance, std::make_shared<InstanceData>};
}
Exemplo n.º 26
0
LRESULT CALLBACK EditProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static bool Tracking = false;

    switch (iMsg)
    {
    case WM_CREATE:
    {
        return 0;
    }
    case WM_MOUSEMOVE:
    {
        if (!Tracking)
        {
            Tracking = true;
            TRACKMOUSEEVENT TM;
            TM.cbSize = sizeof(TM);
            TM.dwFlags = TME_HOVER | TME_LEAVE;
            TM.dwHoverTime = HOVER_DEFAULT;
            TM.hwndTrack = hWnd;
            bool b = (bool)TrackMouseEvent(&TM);
        }
        return 0;
    }
    case WM_MOUSELEAVE:
    {
        Tracking = false;
        return 0;
    }
    case WM_MOUSEHOVER: //word detection
    {
        DWORD Index = SendMessage(hWnd, EM_CHARFROMPOS, wParam, lParam); //line = HIWORD, charindex = LOWORD
        int length = SendMessage(hWnd, EM_LINELENGTH, LOWORD(Index), 0);
        int x = LOWORD(lParam);
        int y = HIWORD(lParam);

        TCHAR* line = new TCHAR[length+1]();
        int linenum = HIWORD(Index);
        WORD* firstwordoftheline = (WORD*)line;
        *firstwordoftheline = length + 1;
        int len = SendMessage(hWnd, EM_GETLINE, HIWORD(Index), (LPARAM)line);


        DWORD charStart = SendMessage(hWnd, EM_LINEINDEX, HIWORD(Index), 0);

        int w_start, w_end;

        if (line[LOWORD(Index) - charStart] != ' ')
        {
            for (w_start = LOWORD(Index) - charStart; w_start >= 0; --w_start)
            {
                if (line[w_start] == ' ')
                {
                    break;
                }
            }
            ++w_start;
            for (w_end = LOWORD(Index) - charStart; w_end < length; ++w_end)
            {
                if (line[w_end] == ' ')
                {
                    line[w_end] = '\0';
                    break;
                }
            }

            while (w_start < w_end)
            {
                if (!IsCharAlpha(line[w_start]))
                    ++w_start;
                else if (!IsCharAlpha(line[w_end]))
                    --w_end;
                else break;
            }
            ++w_end;
            GetDefinition(line + w_start, w_end - w_start);

        }
        delete[] line;
        Tracking = false;
        return 0;
    }

    }
    return OldEditProc(hWnd, iMsg, wParam, lParam);
}