コード例 #1
0
void
PluginIdentifierChild::StartTemporary()
{
  if (mCanonicalIdentifier) {
    NS_ASSERTION(mCanonicalIdentifier->mHashed && mCanonicalIdentifier->mTemporaryRefs == 0,
                 "Canonical identifiers should always be permanent.");
    return; // nothing to do
  }

  if (!mHashed) {
    NS_ASSERTION(mTemporaryRefs == 0, "Not hashed, but temporary refs?");

    PluginIdentifierChild* c = GetCanonical();
    if (c) {
      NS_ASSERTION(c != this, "How did I get in the hash?");
      mCanonicalIdentifier = c;
      NS_ASSERTION(mCanonicalIdentifier->mHashed && mCanonicalIdentifier->mTemporaryRefs == 0,
                   "Canonical identifiers should always be permanent.");
      return;
    }

    Hash();
    mHashed = true;
    mTemporaryRefs = 1;
    return;
  }

  if (mTemporaryRefs)
    ++mTemporaryRefs;
}
コード例 #2
0
ファイル: pgType.cpp プロジェクト: Joe-xXx/pgadmin3
void pgType::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	wxString query;
	wxString collation;

	if (!expandedKids)
	{
		expandedKids = true;
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			query = wxT("SELECT attname, format_type(t.oid,NULL) AS typname, attndims, atttypmod, nsp.nspname,\n")
			        wxT("       (SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT(",\n       collname, nspc.nspname as collnspname");
			query += wxT("\n  FROM pg_attribute att\n")
			         wxT("  JOIN pg_type t ON t.oid=atttypid\n")
			         wxT("  JOIN pg_namespace nsp ON t.typnamespace=nsp.oid\n")
			         wxT("  LEFT OUTER JOIN pg_type b ON t.typelem=b.oid\n");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT("  LEFT OUTER JOIN pg_collation c ON att.attcollation=c.oid\n")
				         wxT("  LEFT OUTER JOIN pg_namespace nspc ON c.collnamespace=nspc.oid\n");
			query += wxT(" WHERE att.attrelid=") + NumToStr(relOid) + wxT("\n")
			         wxT(" ORDER by attnum");
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				int anzvar = 0;
				while (!set->Eof())
				{
					wxString element;
					if (anzvar++)
					{
						typesList += wxT(", ");
						quotedTypesList += wxT(",\n    ");
					}
					typesList += set->GetVal(wxT("attname")) + wxT(" ");
					typesArray.Add(set->GetVal(wxT("attname")));
					quotedTypesList += qtIdent(set->GetVal(wxT("attname"))) + wxT(" ");

					pgDatatype dt(set->GetVal(wxT("nspname")), set->GetVal(wxT("typname")),
					              set->GetBool(wxT("isdup")), set->GetLong(wxT("attndims")) > 0, set->GetLong(wxT("atttypmod")));

					wxString nspname = set->GetVal(wxT("nspname"));

					typesList += dt.GetSchemaPrefix(GetDatabase()) + dt.FullName();
					typesArray.Add(dt.GetSchemaPrefix(GetDatabase()) + dt.FullName());
					quotedTypesList += dt.GetQuotedSchemaPrefix(GetDatabase()) + dt.QuotedFullName();

					if (GetConnection()->BackendMinimumVersion(9, 1))
					{
						if (set->GetVal(wxT("collname")).IsEmpty() || (set->GetVal(wxT("collname")) == wxT("default") && set->GetVal(wxT("collnspname")) == wxT("pg_catalog")))
							collation = wxEmptyString;
						else
						{
							collation = qtIdent(set->GetVal(wxT("collnspname"))) + wxT(".") + qtIdent(set->GetVal(wxT("collname")));
							quotedTypesList += wxT(" COLLATE ") + collation;
						}
						collationsArray.Add(collation);
					}
					typesArray.Add(collation);

					set->MoveNext();
				}
				delete set;
			}
		}
		else if (GetTypeClass() == TYPE_ENUM)
		{
			query = wxT("SELECT enumlabel\n")
			        wxT("  FROM pg_enum\n")
			        wxT(" WHERE enumtypid=") + GetOidStr() + wxT("\n");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT(" ORDER by enumsortorder");
			else
				query += wxT(" ORDER by oid");
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				int anzvar = 0;
				while (!set->Eof())
				{
					wxString element;
					if (anzvar++)
					{
						labelList += wxT(", ");
						quotedLabelList += wxT(",\n    ");
					}
					labelList += set->GetVal(wxT("enumlabel"));
					labelArray.Add(set->GetVal(wxT("enumlabel")));
					quotedLabelList += GetDatabase()->connection()->qtDbString(set->GetVal(wxT("enumlabel")));

					set->MoveNext();
				}
				delete set;
			}
		}
		else if (GetTypeClass() == TYPE_RANGE)
		{
			query = wxT("SELECT rngsubtype, st.typname, ")
			        wxT("rngcollation, col.collname, ")
			        wxT("rngsubopc, opc.opcname, ")
			        wxT("rngcanonical, rngsubdiff\n")
			        wxT("FROM pg_range\n")
			        wxT("LEFT JOIN pg_type st ON st.oid=rngsubtype\n")
			        wxT("LEFT JOIN pg_collation col ON col.oid=rngcollation\n")
			        wxT("LEFT JOIN pg_opclass opc ON opc.oid=rngsubopc\n")
			        wxT("WHERE rngtypid=") + GetOidStr();
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				iSetSubtypeFunction(set->GetLong(wxT("rngsubtype")));
				iSetSubtypeFunctionStr(set->GetVal(wxT("typname")));
				iSetCollationFunction(set->GetLong(wxT("rngcollation")));
				iSetCollationFunctionStr(set->GetVal(wxT("collname")));
				iSetSubtypeOpClassFunction(set->GetLong(wxT("rngsubopc")));
				iSetSubtypeOpClassFunctionStr(set->GetVal(wxT("opcname")));
				if (set->GetVal(wxT("rngcanonical")) != wxT("-"))
					iSetCanonical(set->GetVal(wxT("rngcanonical")));
				if (set->GetVal(wxT("rngsubdiff")) != wxT("-"))
					iSetSubtypeDiff(set->GetVal(wxT("rngsubdiff")));
			}
		}
	}

	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		if (GetConnection()->BackendMinimumVersion(9, 2))
			properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Alias"), GetAlias());
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			properties->AppendItem(_("Members"), GetTypesList());
		}
		if (GetTypeClass() == TYPE_ENUM)
		{
			properties->AppendItem(_("Labels"), GetLabelList());
		}
		else if (GetTypeClass() == TYPE_RANGE)
		{
			properties->AppendItem(_("Subtype"), GetSubtypeFunctionStr());
			properties->AppendItem(_("Collation"), GetCollationFunctionStr());
			properties->AppendItem(_("Subtype OpClass"), GetSubtypeOpClassFunctionStr());
			properties->AppendItem(_("Canonical"), GetCanonical());
			properties->AppendItem(_("Subtype diff"), GetSubtypeDiff());
		}
		else
		{
			properties->AppendItem(_("Alignment"), GetAlignment());
			properties->AppendItem(_("Internal length"), GetInternalLength());
			properties->AppendItem(_("Default"), GetDefault());
			properties->AppendItem(_("Passed by Value?"), BoolToYesNo(GetPassedByValue()));
			if (!GetElement().IsEmpty())
			{
				properties->AppendItem(_("Element"), GetElement());
				properties->AppendItem(_("Delimiter"), GetDelimiter());
			}
			properties->AppendItem(_("Input function"), GetInputFunction());
			properties->AppendItem(_("Output function"), GetOutputFunction());
			if (GetConnection()->BackendMinimumVersion(7, 4))
			{
				properties->AppendItem(_("Receive function"), GetReceiveFunction());
				properties->AppendItem(_("Send function"), GetSendFunction());
				properties->AppendItem(_("Analyze function"), GetAnalyzeFunction());
			}
			if (GetConnection()->BackendMinimumVersion(8, 4))
			{
				properties->AppendItem(_("Category"), GetCategory());
				properties->AppendItem(_("Prefered?"), BoolToYesNo(GetPrefered()));
			}
			if (GetConnection()->BackendMinimumVersion(8, 3))
			{
				if (GetTypmodinFunction().Length() > 0)
					properties->AppendItem(_("Typmod in function"), GetTypmodinFunction());
				if (GetTypmodoutFunction().Length() > 0)
					properties->AppendItem(_("Typmod out function"), GetTypmodoutFunction());
			}
			properties->AppendItem(_("Storage"), GetStorage());
			if (GetConnection()->BackendMinimumVersion(9, 1))
				properties->AppendItem(_("Collatable?"), BoolToYesNo(GetCollatable()));
		}
		properties->AppendYesNoItem(_("System type?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		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));
				}
			}
		}
	}
}
コード例 #3
0
ファイル: box.c プロジェクト: axelmuhr/Helios-NG
void Box::Resize () {
    register BoxElement* e;	/* box element */
    Shape aggrshape;		/* combined shape of components */
    BoxCanonical total;		/* components' shape along major axis */
    int major, minor;		/* actual dimensions of box */
    register int have;		/* how much box is willing to change */
    register int need;		/* how much box needs to change to fit */
    boolean grow;		/* true if stretching, false if shrinking */
    BoxCanonical s;		/* element shape along major axis */
    register int pos;		/* where to put next element on major axis */
    register int len;		/* size of element along major axis */
    register int n;		/* temporary variable */

    ComputeShape(&aggrshape);
    GetActual(major, minor);
    GetCanonical(&aggrshape, total);
    n = total.major.natural;
    if (major > n) {
	/* more space than desired ==> stretch elements */
	grow = true;
	have = total.major.stretch;
	need = min(major - n, have);
    } else {
	/* less (or equal) space than desired ==> (maybe) shrink elements */
	grow = false;
	have = total.major.shrink;
	need = min(n - major, have);
    }
    pos = 0;
    for (e = head; e != nil; e = e->next) {
	GetCanonical(e->child->GetShape(), s);
	len = s.major.natural;
	if (have > 0) {
	    if (grow) {
		n = int(double(s.major.stretch)*double(need)/double(have));
		len += n;
		have -= s.major.stretch;
	    } else {
		n = int(double(s.major.shrink)*double(need)/double(have));
		len -= n;
		have -= s.major.shrink;
	    }
	    need -= n;
	}
	n = s.minor.natural;
	if (n == 0) {
	    n = minor;
	} else if (n > minor) {
	    n = max(n - s.minor.shrink, minor);
	} else if (n < minor) {
	    n = min(n + s.minor.stretch, minor);
	}
	if (n > 0 && len > 0) {
	    e->visible = true;
	    PlaceElement(e->child, pos, len, minor, n);
	} else {
	    e->visible = false;
	}
	pos += len;
    }
}