Ejemplo n.º 1
0
 public void FindInDictionary(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess, IVwSelection sel)
 {
     using (FdoCache cache = new FdoCache(ode, mdc, oleDbAccess))
     {
         if (sel == null)
         {
             return;
         }
         IVwSelection sel2 = sel.EndPoint(false);
         if (sel2 == null)
         {
             return;
         }
         IVwSelection sel3 = sel2.GrowToWord();
         if (sel3 == null)
         {
             return;
         }
         ITsString tss;
         int       ichMin, ichLim, hvo, tag, ws;
         bool      fAssocPrev;
         sel3.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws);
         sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws);
         // TODO (TimS): need to supply help information (last 2 params)
         LexEntryUi.DisplayOrCreateEntry(cache, hvo, tag, ws, ichMin, ichLim, null, null, null, string.Empty);
         return;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            base.Dispose(disposing);

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_xmlVc != null)
                {
                    m_xmlVc.Dispose();
                }
            }
            m_xmlVc       = null;
            m_layoutName  = null;
            m_sXmlSpec    = null;
            m_docSpec     = null;
            m_xnSpec      = null;
            m_mdc         = null;
            m_stringTable = null;
        }
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FwModelBrowser"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FwModelBrowser()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

#if USINGCPP
			m_ode = OleDbEncapClass.Create();
			m_ode.Init(SystemInformation.ComputerName + "\\SILFW", "TestLangProj", null,
				FwKernelLib.OdeLockTimeoutMode.koltReturnError,
				(int)FwKernelLib.OdeLockTimeoutValue.koltvFwDefault);
			m_mdc = FwMetaDataCacheClass.Create();
			m_mdc.Init(m_ode);
#else
			string modelDir = DirectoryFinder.FwSourceDirectory;
			modelDir = modelDir.Substring(0, modelDir.LastIndexOf('\\'));
			modelDir = Path.Combine(modelDir, @"Output\XMI");
			m_mdc = MetaDataCache.CreateMetaDataCache(Path.Combine(modelDir, "xmi2cellar3.xml"));
#endif

			uint clid = 0;
			string classname = m_mdc.GetClassName(clid);
			m_tvClasses.SuspendLayout();
			AddNode(m_tvClasses.Nodes, classname, clid);
			m_tvClasses.Nodes[0].Expand();
			m_tvClasses.ResumeLayout(false);
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_map != null)
                {
                    m_map.Clear();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mdc             = null;
            m_layoutInventory = null;
            m_partInventory   = null;
            m_map             = null;

            m_isDisposed = true;
        }
Ejemplo n.º 5
0
        public void Teardown()
        {
            if (m_wsf != null && Marshal.IsComObject(m_wsf))
            {
                m_wsf.Shutdown();
                Marshal.ReleaseComObject(m_wsf);
            }
            m_wsf = null;

            if (Marshal.IsComObject(m_cda))
            {
                Marshal.ReleaseComObject(m_cda);
            }
            m_cda = null;

            if (Marshal.IsComObject(m_mdc))
            {
                Marshal.ReleaseComObject(m_mdc);
            }
            m_mdc = null;

            if (Marshal.IsComObject(m_sda))
            {
                Marshal.ReleaseComObject(m_sda);
            }
            m_sda = null;

            m_layoutInventory = null;
            m_columnList      = null;
            m_layouts         = null;
            m_partInventory   = null;
        }
Ejemplo n.º 6
0
		public virtual void FixtureSetup()
		{
			string bogusDataPathname = "Good.xml";
			StreamWriter w = File.CreateText(bogusDataPathname);
			w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
			w.WriteLine("<EntireModel>");
				w.WriteLine("<CellarModule id='cellar' num='0'>");
					w.WriteLine("<class num='1' id='MyClass' abstract='false' base='CmObject' >");
						w.WriteLine("<props>");
							//  flid='1001'
						w.WriteLine("<basic num='1' id='myField' sig='int' userlabel='My Field' fieldhelp='Abandon hope' fieldxml='Some stuff' listroot='25' wsselector='10'/>");
						//  flid='1002' kcptNumeric = 3, Not used in official model
						w.WriteLine("<basic num='2' id='myField' sig='Numeric'/>");
						//  flid='1003' kcptFloat = 4, Not used in official model
						w.WriteLine("<basic num='3' id='myField' sig='Float'/>");
						//  flid='1004' kcptImage = 7, Not used in official model
						w.WriteLine("<basic num='4' id='myField' sig='Image'/>");
						//  flid='1005' kcptMultiBigUnicode = 20, Not used in official model
						w.WriteLine("<basic num='5' id='myField' sig='MultiUnicode' big='true'/>");
						w.WriteLine("</props>");
					w.WriteLine("</class>");
				w.WriteLine("</CellarModule>");
			w.WriteLine("</EntireModel>");
			w.Flush();
			w.Close();
			try
			{
				m_mdc = MetaDataCache.CreateMetaDataCache(bogusDataPathname);
			}
			finally
			{
				File.Delete(bogusDataPathname);
			}
		}
Ejemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FwModelBrowser"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public FwModelBrowser()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

#if USINGCPP
            m_ode = OleDbEncapClass.Create();
            m_ode.Init(SystemInformation.ComputerName + "\\SILFW", "TestLangProj", null,
                       FwKernelLib.OdeLockTimeoutMode.koltReturnError,
                       (int)FwKernelLib.OdeLockTimeoutValue.koltvFwDefault);
            m_mdc = FwMetaDataCacheClass.Create();
            m_mdc.Init(m_ode);
#else
            string modelDir = DirectoryFinder.FwSourceDirectory;
            modelDir = modelDir.Substring(0, modelDir.LastIndexOf('\\'));
            modelDir = Path.Combine(modelDir, @"Output\XMI");
            m_mdc    = MetaDataCache.CreateMetaDataCache(Path.Combine(modelDir, "xmi2cellar3.xml"));
#endif

            uint   clid      = 0;
            string classname = m_mdc.GetClassName(clid);
            m_tvClasses.SuspendLayout();
            AddNode(m_tvClasses.Nodes, classname, clid);
            m_tvClasses.Nodes[0].Expand();
            m_tvClasses.ResumeLayout(false);
        }
Ejemplo n.º 8
0
		public SimpleDataParser(IFwMetaDataCache mdc, IVwCacheDa cda)
		{
			m_mdc = mdc;
			m_cda = cda;
			m_sda = cda as ISilDataAccess;
			m_wsf = m_sda.WritingSystemFactory;
		}
Ejemplo n.º 9
0
 public SimpleDataParser(IFwMetaDataCache mdc, IVwCacheDa cda)
 {
     m_mdc = mdc;
     m_cda = cda;
     m_sda = (ISilDataAccess)cda;
     m_wsf = m_sda.WritingSystemFactory;
 }
Ejemplo n.º 10
0
        internal void DumpFieldInfo(IFwMetaDataCache mdc)
        {
            if (this.Depth == 0)
            {
                Debug.WriteLine("");
            }
            for (int i = 0; i < this.Depth; ++i)
            {
                Debug.Write("    ");
            }
            if (Source != 0)
            {
                Debug.WriteLine("[" + this.Depth + "]info.Source = " + this.Source + " = " +
                                GetFancyFieldName(this.Source, mdc));
            }
            else
            {
                Debug.WriteLine("Root (target) class: " + mdc.GetClassName(m_targetClass));
            }

            for (int i = 0; i < this.AtomicFields.Count; ++i)
            {
                for (int j = 0; j < this.Depth; ++j)
                {
                    Debug.Write("    ");
                }
                Debug.WriteLine("    Atomic[" + i + "] flid = " + this.AtomicFields[i].flid + "(" +
                                GetFancyFieldName(this.AtomicFields[i].flid, mdc) + "); ws = " + this.AtomicFields[i].ws);
            }
            for (int i = 0; i < this.SeqFields.Count; ++i)
            {
                this.SeqFields[i].DumpFieldInfo(mdc);
            }
        }
Ejemplo n.º 11
0
		public XUpdater(FdoCache cache, string sFxtPath)
		{
			m_cache = cache;
			FxtDocument = new XmlDocument();
			FxtDocument.Load(sFxtPath);
			m_mdc = m_cache.MetaDataCacheAccessor;
		}
Ejemplo n.º 12
0
        private string GetFancyFieldName(int flid, IFwMetaDataCache mdc)
        {
            string f = mdc.GetFieldName(flid);
            string c = mdc.GetOwnClsName(flid);

            return(c + '_' + f);
        }
Ejemplo n.º 13
0
        public void Teardown()
        {
            if (Marshal.IsComObject(m_cda))
            {
                Marshal.ReleaseComObject(m_cda);
            }
            m_cda = null;

            if (Marshal.IsComObject(m_mdc))
            {
                Marshal.ReleaseComObject(m_mdc);
            }
            m_mdc = null;

            if (Marshal.IsComObject(m_sda))
            {
                Marshal.ReleaseComObject(m_sda);
            }
            m_sda = null;

            m_layoutInventory = null;
            m_columnList      = null;
            m_layouts         = null;
            m_partInventory   = null;
            m_wsManager       = null;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                // does not belong to us!
//				if (m_layouts != null)
//					m_layouts.Dispose();
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_sda        = null;
            m_layoutName = null;
            m_mdc        = null;
            m_cache      = null;
            m_layouts    = null;
            m_colSpec    = null;

            m_isDisposed = true;
        }
Ejemplo n.º 15
0
        static internal int GetCustomFieldFlid(XmlNode caller, IFwMetaDataCache mdc, ICmObject obj)
        {
            string fieldName = XmlUtils.GetManditoryAttributeValue(caller, "param");
            int    flid      = (int)mdc.GetFieldId2((uint)obj.ClassID, fieldName, true);

            return(flid);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            // m_sda COM object block removed due to crash in Finializer thread LT-6124

            if (disposing)
            {
                if (m_sda != null)
                {
                    m_sda.RemoveNotification(this);
                }

                if (m_cache.CreateModifyManager == this)
                {
                    m_cache.CreateModifyManager = null;
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_sda        = null;
            m_cache      = null;        // ensures it can't be used again without crashing.
            m_mdc        = null;
            m_recentMods = null;

            m_isDisposed = true;
        }
Ejemplo n.º 17
0
		/// <summary>
		/// initialize fields based on input node.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="input"></param>
		protected virtual void InitMemberVariablesFromInput(IFwMetaDataCache mdc, XmlNode input)
		{
			m_className = XmlUtils.GetManditoryAttributeValue(input, "class");
			m_clsid = mdc.GetClassId(m_className);
			m_fieldType = XmlUtils.GetManditoryAttributeValue(input, "fieldType");
			m_restrictions = XmlUtils.GetOptionalAttributeValue(input, "restrictions", "none");
			m_source = XmlUtils.GetFirstNonCommentChild(input);
		}
Ejemplo n.º 18
0
		/// <summary>
		/// Make a part generator for the specified "generate" element, interpreting names
		/// using the specified metadatacache, using vc and rootClassId for handling generate nodes
		/// that refer to layouts.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="input"></param>
		/// <param name="vc">for parts/layouts</param>
		/// <param name="rootClassId">class of root object from which column layouts can be computed</param>
		public PartGenerator(IFwMetaDataCache mdc, XmlNode input, XmlVc vc, int rootClassId)
		{
			m_mdc = mdc;
			m_vc = vc;
			m_rootClassId = rootClassId;
			m_input = input;
			InitMemberVariablesFromInput(mdc, input);
		}
Ejemplo n.º 19
0
 /// <summary>
 /// initialize fields based on input node.
 /// </summary>
 /// <param name="mdc"></param>
 /// <param name="input"></param>
 protected virtual void InitMemberVariablesFromInput(IFwMetaDataCache mdc, XmlNode input)
 {
     m_className    = XmlUtils.GetManditoryAttributeValue(input, "class");
     m_clsid        = mdc.GetClassId(m_className);
     m_fieldType    = XmlUtils.GetManditoryAttributeValue(input, "fieldType");
     m_restrictions = XmlUtils.GetOptionalAttributeValue(input, "restrictions", "none");
     m_source       = XmlUtils.GetFirstNonCommentChild(input);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Make a part generator for the specified "generate" element, interpreting names
 /// using the specified metadatacache, using vc and rootClassId for handling generate nodes
 /// that refer to layouts.
 /// </summary>
 /// <param name="mdc"></param>
 /// <param name="input"></param>
 /// <param name="vc">for parts/layouts</param>
 /// <param name="rootClassId">class of root object from which column layouts can be computed</param>
 public PartGenerator(IFwMetaDataCache mdc, XmlNode input, XmlVc vc, int rootClassId)
 {
     m_mdc         = mdc;
     m_vc          = vc;
     m_rootClassId = rootClassId;
     m_input       = input;
     InitMemberVariablesFromInput(mdc, input);
 }
Ejemplo n.º 21
0
		/// <summary>
		/// Make a part generator for the specified "generate" element, interpreting names
		/// using the specified metadatacache, using vc and rootClassId for handling generate nodes
		/// that refer to layouts.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="input"></param>
		/// <param name="vc">for parts/layouts</param>
		/// <param name="rootClassId">class of root object from which column layouts can be computed</param>
		public PartGenerator(FdoCache cache, XmlNode input, XmlVc vc, int rootClassId)
		{
			m_cache = cache;
			m_mdc = cache.MetaDataCacheAccessor;
			m_vc = vc;
			m_rootClassId = rootClassId;
			m_input = input;
			InitMemberVariablesFromInput(cache.MetaDataCacheAccessor, input);
		}
Ejemplo n.º 22
0
 public virtual void FixtureSetup()
 {
     FileUtils.Manager.SetFileAdapter(new MockFileOS());
     using (TextWriter fw = FileUtils.OpenFileForWrite("TestModel.xsd", Encoding.UTF8))
         fw.Write(Properties.Resources.TestModel_xsd);
     using (TextWriter fw = FileUtils.OpenFileForWrite("TestModel.xml", Encoding.UTF8))
         fw.Write(Properties.Resources.TestModel_xml);
     m_metaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml");
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Make a part generator for the specified "generate" element, interpreting names
 /// using the specified metadatacache, using vc and rootClassId for handling generate nodes
 /// that refer to layouts.
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="input"></param>
 /// <param name="vc">for parts/layouts</param>
 /// <param name="rootClassId">class of root object from which column layouts can be computed</param>
 public PartGenerator(FdoCache cache, XmlNode input, XmlVc vc, int rootClassId)
 {
     m_cache       = cache;
     m_mdc         = cache.MetaDataCacheAccessor;
     m_vc          = vc;
     m_rootClassId = rootClassId;
     m_input       = input;
     InitMemberVariablesFromInput(cache.MetaDataCacheAccessor, input);
 }
Ejemplo n.º 24
0
        static internal void EliminateExtraStyleAndWsInfo(IFwMetaDataCache mdc, FwPasteFixTssEventArgs e, int flid)
        {
            var type = (CellarPropertyType)mdc.GetFieldType(flid);

            if (type == CellarPropertyType.MultiUnicode ||
                type == CellarPropertyType.Unicode)
            {
                e.TsString = e.TsString.ToWsOnlyString();
            }
        }
Ejemplo n.º 25
0
		/// <summary>
		///
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="tbl"></param>
		/// <param name="clsId"></param>
		/// <param name="titleStr">*{dstClass}* if couldn't find result.</param>
		/// <returns>true if we found an alternate form. false if titleStr is null or in *{ClassName}* format.</returns>
		public static bool TryFindPluralFormFromClassId(IFwMetaDataCache mdc, StringTable tbl, int clsId, out string titleStr)
		{
			titleStr = null;
			if (clsId != 0)
			{
				string className = mdc.GetClassName(clsId);
				return TryFindString(tbl, "AlternativeTitles", String.Format("{0}-Plural", className), out titleStr);
			}
			return false;
		}
Ejemplo n.º 26
0
        /// <summary>
        /// Create one and install it to work on a particular cache.
        /// </summary>
        /// <param name="cache"></param>
        public CreateModifyTimeManager(FdoCache cache)
        {
            m_cache = cache;
            Debug.Assert(cache.CreateModifyManager == null);
            cache.CreateModifyManager = this;

            m_sda = cache.MainCacheAccessor;
            m_sda.AddNotification(this);

            m_mdc = cache.MetaDataCacheAccessor;
        }
Ejemplo n.º 27
0
		/// <summary>
		/// Create one and install it to work on a particular cache.
		/// </summary>
		/// <param name="cache"></param>
		public CreateModifyTimeManager(FdoCache cache)
		{
			m_cache = cache;
			Debug.Assert(cache.CreateModifyManager == null);
			cache.CreateModifyManager = this;

			m_sda = cache.MainCacheAccessor;
			m_sda.AddNotification(this);

			m_mdc = cache.MetaDataCacheAccessor;
		}
Ejemplo n.º 28
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        private void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_wsCache != null)
                {
                    m_wsCache.Clear();
                }
                if (m_delayedAtomicReferences != null)
                {
                    m_delayedAtomicReferences.Clear();
                }
                if (m_delayedVecterReferences != null)
                {
                    m_delayedVecterReferences.Clear();
                }
                if (m_cachedFlids != null)
                {
                    m_cachedFlids.Clear();
                }
                if (m_tsf != null)
                {
                    m_tsf.Dispose();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.

            if (m_itsf != null)
            {
                if (Marshal.IsComObject(m_itsf))
                {
                    Marshal.ReleaseComObject(m_itsf);
                }
                m_itsf = null;
            }
            m_tsf                     = null;
            m_metaDataCache           = null;
            m_realDataCache           = null;
            m_wsCache                 = null;
            m_delayedAtomicReferences = null;
            m_delayedVecterReferences = null;
            m_cachedFlids             = null;

            m_isDisposed = true;
        }
Ejemplo n.º 29
0
 private void InitializeDynamically(IFwMetaDataCache mdc, bool fLoadFlexLayouts, string sDatabase)
 {
     m_mdc             = mdc;
     m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
     m_partInventory   = Inventory.GetInventory("parts", sDatabase);
     if (m_layoutInventory == null || m_partInventory == null)
     {
         InitializePartInventories(fLoadFlexLayouts, sDatabase);
         m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
         m_partInventory   = Inventory.GetInventory("parts", sDatabase);
     }
 }
Ejemplo n.º 30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="LayoutCache"/> class.
		/// </summary>
		/// <param name="mdc">The MDC.</param>
		/// <param name="sDatabase">The database name.</param>
		/// <param name="app">The application.</param>
		/// <param name="projectPath">The project folder.</param>
		/// ------------------------------------------------------------------------------------
		public LayoutCache(IFwMetaDataCache mdc, string sDatabase, IApp app, String projectPath)
		{
			m_mdc = mdc;
			m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
			m_partInventory = Inventory.GetInventory("parts", sDatabase);
			if (m_layoutInventory == null || m_partInventory == null)
			{
				InitializePartInventories(sDatabase, app, projectPath);
				m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
				m_partInventory = Inventory.GetInventory("parts", sDatabase);
			}
		}
Ejemplo n.º 31
0
		private void InitializeDynamically(IFwMetaDataCache mdc, bool fLoadFlexLayouts, string sDatabase)
		{
			m_mdc = mdc;
			m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
			m_partInventory = Inventory.GetInventory("parts", sDatabase);
			if (m_layoutInventory == null || m_partInventory == null)
			{
				InitializePartInventories(fLoadFlexLayouts, sDatabase);
				m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
				m_partInventory = Inventory.GetInventory("parts", sDatabase);
			}
		}
Ejemplo n.º 32
0
        bool m_fGotFocus = false;         // True if we have focus.

        public TypeAheadSupportVc(int tag, LcmCache cache)
        {
            m_tag = tag;
            IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache;

            m_clid      = mdc.GetOwnClsId(m_tag);
            m_className = mdc.GetClassName(m_clid);
            m_fieldName = mdc.GetFieldName(m_tag);
            m_type      = (CellarPropertyType)(mdc.GetFieldType(m_tag) & (int)CellarPropertyTypeFilter.VirtualMask);
            m_sda       = cache.DomainDataByFlid;
            Cache       = cache;
        }
Ejemplo n.º 33
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="LayoutCache"/> class.
 /// </summary>
 /// <param name="mdc">The MDC.</param>
 /// <param name="sDatabase">The database name.</param>
 /// <param name="app">The application.</param>
 /// <param name="projectPath">The project folder.</param>
 /// ------------------------------------------------------------------------------------
 public LayoutCache(IFwMetaDataCache mdc, string sDatabase, IApp app, String projectPath)
 {
     m_mdc             = mdc;
     m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
     m_partInventory   = Inventory.GetInventory("parts", sDatabase);
     if (m_layoutInventory == null || m_partInventory == null)
     {
         InitializePartInventories(sDatabase, app, projectPath);
         m_layoutInventory = Inventory.GetInventory("layouts", sDatabase);
         m_partInventory   = Inventory.GetInventory("parts", sDatabase);
     }
 }
Ejemplo n.º 34
0
		/// <summary>
		/// looks up plural form alternative first for given flid, secondly for its destination class.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="tbl"></param>
		/// <param name="owningFlid"></param>
		/// <param name="titleStr">*{dstClass}* if couldn't find result.</param>
		/// <returns>true if we found an alternate form. false if titleStr is null or in *{key}* format.</returns>
		public static bool TryFindPluralFormFromFlid(IFwMetaDataCache mdc, StringTable tbl, int owningFlid, out string titleStr)
		{
			// first see if we can find an expanded name for the name of a flid.
			string flidName = mdc.GetFieldName(owningFlid);
			if (!String.IsNullOrEmpty(flidName))
			{
				if (TryFindString(tbl, "AlternativeTitles", flidName, out titleStr))
					return true;
			}
			// secondly, see if we can find the plural form for the destination class.
			int dstClass = mdc.GetDstClsId(owningFlid);
			return TryFindPluralFormFromClassId(mdc, tbl, dstClass, out titleStr);
		}
Ejemplo n.º 35
0
        public static LfMultiParagraph GetCustomStTextValuesAsLfMultiPara(IStText obj, int flid,
			IWritingSystemManager wsManager, IFwMetaDataCache metaDataCacheAccessor, int fallbackWs)
        {
            if (obj == null || obj.ParagraphsOS == null || obj.ParagraphsOS.Count == 0) return null;
            var result = new LfMultiParagraph();
            result.Paragraphs = obj.ParagraphsOS.OfType<IStTxtPara>().Where(para => para.Contents != null).Select(para => FdoParaToLfPara(para, wsManager)).ToList();
            // StText objects in FDO have a single primary writing system, unlike MultiString or MultiUnicode objects
            int fieldWs = metaDataCacheAccessor.GetFieldWs(flid);
            string wsStr = wsManager.GetStrFromWs(fieldWs);
            if (wsStr == null) wsStr = wsManager.GetStrFromWs(fallbackWs);
            result.InputSystem = wsStr;
            return result;
        }
Ejemplo n.º 36
0
        public override void Init(FdoCache cache, Mediator mediator, XmlNode recordListNode)
        {
            CheckDisposed();

            // <recordList class="WfiWordform" field="Occurrences"/>
            BaseInit(cache, mediator, recordListNode);
            IFwMetaDataCache mdc = VirtualListPublisher.MetaDataCache;

            m_flid = mdc.GetFieldId2(WfiWordformTags.kClassId, "Occurrences", false);
            Sorter = new OccurrenceSorter
            {
                Cache = cache, SpecialDataAccess = VirtualListPublisher
            };
        }
Ejemplo n.º 37
0
        bool m_fGotFocus = false;         // True if we have focus.

        public TypeAheadSupportVc(int tag, FdoCache cache)
        {
            m_tag = tag;
            IFwMetaDataCache mdc = cache.MetaDataCacheAccessor;

            m_clid      = mdc.GetOwnClsId((uint)m_tag);
            m_className = mdc.GetClassName(m_clid);
            m_fieldName = mdc.GetFieldName((uint)m_tag);
            m_type      = mdc.GetFieldType((uint)m_tag);
            m_type      = m_type & 0x1f;        // strip off virtual bit.
            m_sda       = cache.MainCacheAccessor;
            m_cache     = cache;
            CreateVirtualProperties();
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Set configuration displayProperty from cmObjectCustomFieldFlid set elements' OwningList DisplayOption.
        ///
        /// If cmObjectCustomFieldFlid refers to a set of elements (in cmObject), then examine the setting on the owning list of the
        /// elements to determine which property of each element to use when
        /// displaying each element in a slice, and record that information in configurationNode. This information is used
        /// in DetailControls.VectorReferenceVc.Display().
        /// Addresses LT-15705.
        /// </summary>
        internal static void SetConfigurationDisplayPropertyIfNeeded(XmlNode configurationNode, ICmObject cmObject,
                                                                     int cmObjectCustomFieldFlid, ISilDataAccess mainCacheAccessor, ILcmServiceLocator fdoServiceLocator,
                                                                     IFwMetaDataCache metadataCache)
        {
            var fieldType = metadataCache.GetFieldType(cmObjectCustomFieldFlid);

            if (!(fieldType == (int)CellarPropertyType.ReferenceCollection ||
                  fieldType == (int)CellarPropertyType.OwningCollection ||
                  fieldType == (int)CellarPropertyType.ReferenceSequence ||
                  fieldType == (int)CellarPropertyType.OwningSequence))
            {
                return;
            }

            var element = FetchFirstElementFromSet(cmObject, cmObjectCustomFieldFlid, mainCacheAccessor, fdoServiceLocator);

            if (element == null)
            {
                return;
            }

            var    displayOption            = element.OwningList.DisplayOption;
            string propertyNameToGetAndShow = null;

            switch ((PossNameType)displayOption)
            {
            case PossNameType.kpntName:
                propertyNameToGetAndShow = "ShortNameTSS";
                break;

            case PossNameType.kpntNameAndAbbrev:
                propertyNameToGetAndShow = "AbbrAndNameTSS";
                break;

            case PossNameType.kpntAbbreviation:
                propertyNameToGetAndShow = "AbbrevHierarchyString";
                break;

            default:
                break;
            }
            if (propertyNameToGetAndShow == null)
            {
                return;
            }

            SetDisplayPropertyInXMLConfiguration(configurationNode, propertyNameToGetAndShow);
        }
Ejemplo n.º 39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="root"></param>
        /// <param name="mdc"></param>
        /// <param name="keyAttrNames"></param>
        /// <param name="vc">for parts/layouts</param>
        /// <param name="rootClassId">class of the root object used to compute parts/layouts</param>
        /// <returns></returns>
        static private List <XmlNode> GetGeneratedChildren(XmlNode root, IFwMetaDataCache mdc, string[] keyAttrNames,
                                                           XmlVc vc, int rootClassId)
        {
            List <XmlNode> result = new List <XmlNode>();
            string         generateModeForColumns = XmlUtils.GetOptionalAttributeValue(root, "generate");
            bool           m_fGenerateChildPartsForParentLayouts = (generateModeForColumns == "childPartsForParentLayouts");

            // childPartsForParentLayouts
            foreach (XmlNode child in root.ChildNodes)
            {
                if (child is XmlComment)
                {
                    continue;
                }
                if (m_fGenerateChildPartsForParentLayouts)
                {
                    ChildPartGenerator cpg = new ChildPartGenerator(mdc, child, vc, rootClassId);
                    cpg.GenerateChildPartsIfNeeded();
                }
                if (child.Name != "generate")
                {
                    result.Add(child);
                    continue;
                }

                PartGenerator generator = new PartGenerator(mdc, child, vc, rootClassId);
                foreach (XmlNode genNode in generator.Generate())
                {
                    bool match = false;
                    if (keyAttrNames != null)
                    {
                        foreach (XmlNode matchNode in root.ChildNodes)
                        {
                            if (MatchNodes(matchNode, genNode, keyAttrNames))
                            {
                                match = true;
                                break;
                            }
                        }
                    }
                    if (!match)                     // not already present, or not checking; add it.
                    {
                        result.Add(genNode);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 40
0
        static internal int GetCustomFieldFlid(XmlNode caller, IFwMetaDataCache mdc, ICmObject obj)
        {
            string fieldName = XmlUtils.GetManditoryAttributeValue(caller, "param");

            // It would be nice to avoid all the possible throws for invalid fields, but hard
            // to achieve in a static method.
            try
            {
                int flid = mdc.GetFieldId2(obj.ClassID, fieldName, true);
                return(flid);
            }
            catch
            {
                return(0);
            }
        }
Ejemplo n.º 41
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mdc"></param>
 /// <param name="input">the column node (not generate node)</param>
 protected override void InitMemberVariablesFromInput(IFwMetaDataCache mdc, XmlNode input)
 {
     if (input.Name == "generate")
     {
         // first column child is the node we want to try to generate.
         m_source = input.SelectSingleNode("./column");
         return;
     }
     else if (input.Name != "column")
     {
         throw new ArgumentException("ChildPartGenerator expects input to be column node, not {0}", input.Name);
     }
     m_source = input;
     //m_clsid = m_rootClassId;
     //m_className = mdc.GetClassName(m_rootClassId);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Get a list of flids for the given class, and type.
        /// </summary>
        /// <param name="mdc"></param>
        /// <param name="clsid"></param>
        /// <param name="flidType"></param>
        /// <returns></returns>
        static public uint[] GetFieldsInClassOfType(IFwMetaDataCache mdc, uint clsid, FieldType flidType)
        {
            uint[] retval    = new uint[0];
            int    nflidType = (int)flidType;
            int    flidCount = mdc.GetFields(clsid, true, nflidType, 0, ArrayPtr.Null);

            if (flidCount > 0)
            {
                using (ArrayPtr rgflid = new ArrayPtr(flidCount * Marshal.SizeOf(typeof(uint))))
                {
                    int flidCount2 = mdc.GetFields(clsid, true, nflidType, flidCount, rgflid);
                    Debug.Assert(flidCount == flidCount2);
                    retval = (uint[])MarshalEx.NativeToArray(rgflid, flidCount, typeof(uint));
                }
            }
            return(retval);
        }
Ejemplo n.º 43
0
        public void GenerateMlCustomString()
        {
            IFwMetaDataCache mdc         = FwMetaDataCacheClass.Create();
            string           m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                                        @"DbAccess\Test\SampleCm.xml");

            mdc.InitXml(m_sTestPath, true);

            XmlDocument docSrc = new XmlDocument();

            docSrc.LoadXml(
                "<generate class=\"LexEntry\" fieldType=\"mlstring\" restrictions=\"customOnly\"> "
                + "<column label=\"$label\"> "
                + "<seq field=\"Senses\" sep=\"$delimiter:commaSpace\"> "
                + "<string field=\"$fieldName\" ws=\"$ws:analysis\" class=\"LexEntry\"/> "
                + "</seq> "
                + "</column> "
                + "</generate>");
            XmlNode source = TestXmlViewsUtils.GetRootNode(docSrc, "generate");

            Assert.IsNotNull(source);

            PartGenerator generator = new PartGenerator(mdc, source);

            string[] fields = generator.FieldNames;
            Assert.AreEqual(1, fields.Length);
            Assert.IsTrue(StringArrayIncludes(fields, "custom"));

            XmlNode[] results = generator.Generate();

            // SampleCm.xml has three ML attrs on LexEntry
            Assert.AreEqual(1, results.Length);

            XmlDocument docExpected3 = new XmlDocument();

            docExpected3.LoadXml(
                "<column label=\"Restrictions\" originalLabel=\"Restrictions\" > "
                + "<seq field=\"Senses\" sep=\"$delimiter:commaSpace\"> "
                + "<string field=\"custom\" ws=\"$ws:analysis\" class=\"LexEntry\"/> "
                + "</seq> "
                + "</column>");
            XmlNode expected3 = TestXmlViewsUtils.GetRootNode(docExpected3, "column");

            Assert.IsTrue(SomeNodeMatches(results, expected3));
        }
Ejemplo n.º 44
0
		public void FindInDictionary(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess, IVwSelection sel)
		{
			using (FdoCache cache = new FdoCache(ode, mdc, oleDbAccess))
			{
				if (sel == null)
					return;
				IVwSelection sel2 = sel.EndPoint(false);
				if (sel2 == null)
					return;
				IVwSelection sel3 = sel2.GrowToWord();
				if (sel3 == null)
					return;
				ITsString tss;
				int ichMin, ichLim, hvo, tag, ws;
				bool fAssocPrev;
				sel3.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws);
				sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws);
				// TODO (TimS): need to supply help information (last 2 params)
				LexEntryUi.DisplayOrCreateEntry(cache, hvo, tag, ws, ichMin, ichLim, null, null, null, string.Empty);
				return;
			}
		}
Ejemplo n.º 45
0
		/// <summary>
		/// Create a RealDataCache object, and laod it with metadata and real data.
		/// </summary>
		/// <param name="metadataPathname"></param>
		/// <param name="realDataPathname"></param>
		/// <param name="objects"></param>
		/// <returns></returns>
		public RealDataCache LoadCache(string metadataPathname, string realDataPathname, Dictionary<int, uint> objects)
		{
			CheckDisposed();

			m_realDataCache = new RealDataCache();
			m_realDataCache.CheckWithMDC = false;

			try
			{
#if DEBUG
				//Process objectBrowser = Process.GetCurrentProcess();
				//long memory = objectBrowser.PrivateMemorySize64;
				//Debug.WriteLine(String.Format("Memory used (start load): {0}.", memory.ToString()));

				DateTime start = DateTime.Now;
#endif
				m_metaDataCache = new MetaDataCache();
				m_metaDataCache.InitXml(metadataPathname, true);
				m_realDataCache.MetaDataCache = m_metaDataCache;
#if DEBUG
				DateTime end = DateTime.Now;
				TimeSpan span = new TimeSpan(end.Ticks - start.Ticks);
				string totalTime = String.Format("Hours: {0}, Minutes: {1}, Seconds: {2}, Millseconds: {3}",
					span.Hours.ToString(), span.Minutes.ToString(), span.Seconds.ToString(), span.Milliseconds.ToString());
				Debug.WriteLine("Time to load MDC: " + totalTime);
				start = end;
				//memory = objectBrowser.PrivateMemorySize64;
				//Debug.WriteLine(String.Format("Memory used (loaded MDC load): {0}.", memory.ToString()));
#endif

				XmlDocument doc = new XmlDocument();
				doc.Load(realDataPathname);
#if DEBUG
				end = DateTime.Now;
				span = new TimeSpan(end.Ticks - start.Ticks);
				totalTime = String.Format("Hours: {0}, Minutes: {1}, Seconds: {2}, Millseconds: {3}",
					span.Hours.ToString(), span.Minutes.ToString(), span.Seconds.ToString(), span.Milliseconds.ToString());
				Debug.WriteLine("Time to load XML: " + totalTime);
				start = end;
				//memory = objectBrowser.PrivateMemorySize64;
				//Debug.WriteLine(String.Format("Memory used (loaded data XML): {0}.", memory.ToString()));
#endif

				// Load Writing Systems first.
				int ord = 0;
				int hvo;
				uint clid = 0;
				{
					XmlNodeList wsNodes = doc.DocumentElement.SelectNodes("LgWritingSystem");
					uint flid = m_metaDataCache.GetFieldId("LgWritingSystem", "ICULocale", false);
					// We need a full list of ints and strings for Wses,
					// before we can load string data,
					// so cache the barebones first.
					foreach (XmlNode wsNode in wsNodes)
					{
						hvo = BootstrapWs(wsNode, flid, out clid, objects);
					}
					foreach (XmlNode wsNode in wsNodes)
					{
						string uid = wsNode.Attributes["id"].Value.Substring(1);
						hvo = m_realDataCache.get_ObjFromGuid(new Guid(uid));
						LoadObject(wsNode, hvo, clid, objects);
					}
				}
				// Now load other ownerless objects, except LangProject and Wses.
				foreach (XmlNode otherOwnerlessNode in doc.DocumentElement.ChildNodes)
				{
					if (otherOwnerlessNode.Name != "LangProject" && otherOwnerlessNode.Name != "LgWritingSystem")
					{
						hvo = LoadCmObjectProperties(otherOwnerlessNode, 0, 0, ord, out clid, objects);
						LoadObject(otherOwnerlessNode, hvo, clid, objects);
					}
				}
				// Now load LangProject
				XmlNode langProjectNode = doc.DocumentElement.SelectSingleNode("LangProject");
				hvo = LoadCmObjectProperties(langProjectNode, 0, 0, ord, out clid, objects);
				LoadObject(langProjectNode, hvo, clid, objects);

				// Set references
				// Set atomic references
				foreach (KeyValuePair<HvoFlidKey, XmlNode> kvp in m_delayedAtomicReferences)
				{
					string uid = kvp.Value.Attributes["target"].Value.Substring(1);
					try
					{
						int hvoTarget = m_realDataCache.get_ObjFromGuid(new Guid(uid));
						m_realDataCache.CacheObjProp(kvp.Key.Hvo, (int)kvp.Key.Flid, hvoTarget);
					}
					catch
					{
						// Invalid reference. Just clear the cache in case there is a save.
						m_realDataCache.SetObjProp(kvp.Key.Hvo, (int)kvp.Key.Flid, 0);
					}
				}
				//// Remove all items from m_delayedAtomicReferences that are in handledRefs.
				//// Theory has it that m_delayedAtomicReferences should then be empty.
				m_delayedAtomicReferences.Clear();

				// Set vector (col or seq) references.
				foreach (KeyValuePair<HvoFlidKey, List<XmlNode>> kvp in m_delayedVecterReferences)
				{
					List<int> hvos = new List<int>();
					foreach (XmlNode obj in kvp.Value)
					{
						string uid = obj.Attributes["target"].Value.Substring(1);
						try
						{
							int ownedHvo = m_realDataCache.get_ObjFromGuid(new Guid(uid));
							hvos.Add(ownedHvo);
						}
						catch
						{
							// Invalid reference. Just remove the bogus hvo.
							// Since the id is added after the exception, it is effectively 'removed'.
							Debug.WriteLine("Bogus Id found.");
						}
					}
					m_realDataCache.CacheVecProp(kvp.Key.Hvo, (int)kvp.Key.Flid, hvos.ToArray(), hvos.Count);
				}
				m_delayedVecterReferences.Clear();
#if DEBUG
				end = DateTime.Now;
				span = new TimeSpan(end.Ticks - start.Ticks);
				totalTime = String.Format("Hours: {0}, Minutes: {1}, Seconds: {2}, Millseconds: {3}",
					span.Hours.ToString(), span.Minutes.ToString(), span.Seconds.ToString(), span.Milliseconds.ToString());
				Debug.WriteLine("Time to load main Cache: " + totalTime);
				start = end;

				Debug.WriteLine(String.Format("Number of objects cached: {0}", (m_realDataCache.NextHvo - 1).ToString()));
				//memory = objectBrowser..PrivateMemorySize64;
				//Debug.WriteLine(String.Format("Memory used (cache loaded): {0}.", memory.ToString()));
#endif
			}
			finally
			{
				m_realDataCache.CheckWithMDC = true;
			}
			return m_realDataCache;
		}
Ejemplo n.º 46
0
		/// <summary>
		/// Initialize the dialog after creating it.
		/// </summary>
		/// <param name="configurationParameters"></param>
		/// <param name="cache"></param>
		/// <param name="styleSheet"></param>
		/// <param name="mainWindowDelegateCallbacks"></param>
		/// <param name="mediator"></param>
		public void SetConfigDlgInfo(XmlNode configurationParameters, FdoCache cache,
			FwStyleSheet styleSheet, IMainWindowDelegateCallbacks mainWindowDelegateCallbacks,
			Mediator mediator, string sLayoutPropertyName)
		{
			CheckDisposed();
			m_configurationParameters = configurationParameters;
			string labelKey = XmlUtils.GetAttributeValue(configurationParameters, "viewTypeLabelKey");
			if (!String.IsNullOrEmpty(labelKey))
			{
				string sLabel = xWorksStrings.ResourceManager.GetString(labelKey);
				if (!String.IsNullOrEmpty(sLabel))
					m_lblViewType.Text = sLabel;
			}
			m_cache = cache;
			m_mdc = m_cache.MetaDataCacheAccessor;
			m_styleSheet = styleSheet;
			m_callbacks = mainWindowDelegateCallbacks;
			m_mediator = mediator;
			m_sLayoutPropertyName = sLayoutPropertyName;
			if (m_mediator != null && m_mediator.HasStringTable)
				m_stringTbl = m_mediator.StringTbl;
			m_layouts = Inventory.GetInventory("layouts", cache.DatabaseName);
			m_parts = Inventory.GetInventory("parts", cache.DatabaseName);
			string configObjectName = XmlUtils.GetLocalizedAttributeValue(m_mediator.StringTbl,
				configurationParameters, "configureObjectName", "");
			this.Text = String.Format(this.Text, configObjectName);
			m_defaultRootLayoutName = XmlUtils.GetAttributeValue(configurationParameters, "layout");
			string sLayoutType = null;
			if (m_mediator != null && m_mediator.PropertyTable != null)
			{
				object objType = m_mediator.PropertyTable.GetValue(m_sLayoutPropertyName);
				if (objType != null)
					sLayoutType = (string)objType;
			}
			if (String.IsNullOrEmpty(sLayoutType))
				sLayoutType = m_defaultRootLayoutName;
			CreateComboAndTreeItems(sLayoutType);

			// Restore the location and size from last time we called this dialog.
			if (m_mediator != null && m_mediator.PropertyTable != null)
			{
				object locWnd = m_mediator.PropertyTable.GetValue("XmlDocConfigureDlg_Location");
				object szWnd = m_mediator.PropertyTable.GetValue("XmlDocConfigureDlg_Size");
				if (locWnd != null && szWnd != null)
				{
					Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
					ScreenUtils.EnsureVisibleRect(ref rect);
					DesktopBounds = rect;
					StartPosition = FormStartPosition.Manual;
				}
			}

			// Make a help topic ID
			m_helpTopicID = generateChooserHelpTopicID(configObjectName);

			// Load the list for the styles combo box.
			SetStylesList();
		}
Ejemplo n.º 47
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		private void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				if (m_wsCache != null)
					m_wsCache.Clear();
				if (m_delayedAtomicReferences != null)
					m_delayedAtomicReferences.Clear();
				if (m_delayedVecterReferences != null)
					m_delayedVecterReferences.Clear();
				if (m_cachedFlids != null)
					m_cachedFlids.Clear();
				if (m_tsf != null)
					m_tsf.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.

			if (m_itsf != null)
			{
				if (Marshal.IsComObject(m_itsf))
					Marshal.ReleaseComObject(m_itsf);
				m_itsf = null;
			}
			m_tsf = null;
			m_metaDataCache = null;
			m_realDataCache = null;
			m_wsCache = null;
			m_delayedAtomicReferences = null;
			m_delayedVecterReferences = null;
			m_cachedFlids = null;

			m_isDisposed = true;
		}
Ejemplo n.º 48
0
		/// <summary>
		/// Get a list of flids for the given class, and type.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="clsid"></param>
		/// <param name="flidType"></param>
		/// <returns></returns>
		static public uint[] GetFieldsInClassOfType(IFwMetaDataCache mdc, uint clsid, FieldType flidType)
		{
			uint[] retval = new uint[0];
			int nflidType = (int)flidType;
			int flidCount = mdc.GetFields(clsid, true, nflidType, 0, ArrayPtr.Null);
			if(flidCount > 0)
			{
				using (ArrayPtr rgflid = new ArrayPtr(flidCount * Marshal.SizeOf(typeof(uint))))
				{
					int flidCount2 = mdc.GetFields(clsid, true, nflidType, flidCount, rgflid);
					Debug.Assert(flidCount == flidCount2);
					retval = (uint[])MarshalEx.NativeToArray(rgflid, flidCount, typeof(uint));
				}
			}
			return retval;
		}
Ejemplo n.º 49
0
		public virtual void FixtureSetup()
		{
			FileUtils.Manager.SetFileAdapter(new MockFileOS());
			using (TextWriter fw = FileUtils.OpenFileForWrite("TestModel.xsd", Encoding.UTF8))
				fw.Write(Properties.Resources.TestModel_xsd);
			using (TextWriter fw = FileUtils.OpenFileForWrite("TestModel.xml", Encoding.UTF8))
				fw.Write(Properties.Resources.TestModel_xml);
			m_metaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml");
		}
Ejemplo n.º 50
0
		/// <summary>
		/// Load the list (given by owner and sFieldName) from the given TextReader.
		/// </summary>
		public void ImportList(ICmObject owner, string sFieldName, TextReader reader, IProgress progress)
		{
			m_cache = owner.Cache;
			m_mdc = m_cache.MetaDataCache;
			m_wsf = m_cache.WritingSystemFactory;
			m_progress = progress;

			NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(m_cache.ActionHandlerAccessor, () =>
				{
					int flidList = m_mdc.GetFieldId(owner.ClassName, sFieldName, true);
					if (flidList == 0)
						throw new Exception(String.Format("Invalid list fieldname (programming error): {0}", sFieldName));
					using (var xrdr = XmlReader.Create(reader))
					{
						xrdr.MoveToContent();
						if (xrdr.Name != owner.ClassName)
							throw new Exception(String.Format("Unexpected outer element: {0}", xrdr.Name));

						if (!xrdr.ReadToDescendant(sFieldName))
							throw new Exception(String.Format("Unexpected second element: {0}", xrdr.Name));

						if (!xrdr.ReadToDescendant("CmPossibilityList"))
							throw new Exception(String.Format("Unexpected third element: {0}", xrdr.Name));

						ICmPossibilityList list;
						int hvo = m_cache.MainCacheAccessor.get_ObjectProp(owner.Hvo, flidList);
						if (hvo == 0)
							hvo = m_cache.MainCacheAccessor.MakeNewObject(CmPossibilityListTags.kClassId, owner.Hvo, flidList, -2);
						ICmPossibilityListRepository repo = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>();
						list = repo.GetObject(hvo);
						string sItemClassName = "CmPossibility";
						xrdr.Read();
						while (xrdr.Depth == 3)
						{
							xrdr.MoveToContent();
							if (xrdr.Depth < 3)
								break;
							switch (xrdr.Name)
							{
								case "Description":
									SetMultiStringFromXml(xrdr, list.Description);
									break;
								case "Name":
									SetMultiUnicodeFromXml(xrdr, list.Name);
									break;
								case "Abbreviation":
									SetMultiUnicodeFromXml(xrdr, list.Abbreviation);
									break;
								case "Depth":
									list.Depth = ReadIntFromXml(xrdr);
									break;
								case "DisplayOption":
									list.DisplayOption = ReadIntFromXml(xrdr);
									break;
								case "HelpFile":
									list.HelpFile = ReadUnicodeFromXml(xrdr);
									break;
								case "IsClosed":
									list.IsClosed = ReadBoolFromXml(xrdr);
									break;
								case "IsSorted":
									list.IsSorted = ReadBoolFromXml(xrdr);
									break;
								case "IsVernacular":
									list.IsVernacular = ReadBoolFromXml(xrdr);
									break;
								case "ItemClsid":
									list.ItemClsid = ReadIntFromXml(xrdr);
									sItemClassName = m_mdc.GetClassName(list.ItemClsid);
									break;
								case "ListVersion":
									list.ListVersion = ReadGuidFromXml(xrdr);
									break;
								case "PreventChoiceAboveLevel":
									list.PreventChoiceAboveLevel = ReadIntFromXml(xrdr);
									break;
								case "PreventDuplicates":
									list.PreventDuplicates = ReadBoolFromXml(xrdr);
									break;
								case "PreventNodeChoices":
									list.PreventNodeChoices = ReadBoolFromXml(xrdr);
									break;
								case "UseExtendedFields":
									list.UseExtendedFields = ReadBoolFromXml(xrdr);
									break;
								case "WsSelector":
									list.WsSelector = ReadIntFromXml(xrdr);
									break;
								case "Possibilities":
									LoadPossibilitiesFromXml(xrdr, list, sItemClassName);
									break;
								case "HeaderFooterSets":
									throw new Exception("We don't (yet?) handle HeaderFooterSets for CmPossibilityList (programming issue)");
								case "Publications":
									throw new Exception("We don't (yet?) handle Publications for CmPossibilityList (programming issue)");
								default:
									throw new Exception(String.Format("Unknown field element in CmPossibilityList: {0}", xrdr.Name));
							}
						}
						xrdr.Close();
						if (m_mapRelatedDomains.Count > 0)
							SetRelatedDomainsLinks();
					}
				});
		}
Ejemplo n.º 51
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		private void Dispose(bool disposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				ClearAllData();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_metaDataCache = null;
			m_actionhandler = null;
			m_lgWritingSystemFactory = null;
			m_basicObjectCache = null;
			m_extendedKeyCache = null;
			m_basicITsStringCache = null;
			m_basicByteArrayCache = null;
			m_guidCache = null;
			m_guidToHvo = null;
			m_intCache = null;
			m_longCache = null;
			m_boolCache = null;
			m_vectorCache = null;
			m_timeStampCache = null;

			m_isDisposed = true;
		}
Ejemplo n.º 52
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected virtual void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_metaDataCache = null;

			m_isDisposed = true;
		}
Ejemplo n.º 53
0
		public virtual void FixtureSetup()
		{
			string modelDir = DirectoryFinder.FwSourceDirectory;
			modelDir = modelDir.Substring(0, modelDir.LastIndexOf('\\'));
			modelDir = Path.Combine(modelDir, @"Output\XMI");
			m_metaDataCache = MetaDataCache.CreateMetaDataCache(Path.Combine(modelDir, "xmi2cellar3.xml"));
		}
Ejemplo n.º 54
0
		internal void DumpFieldInfo(IFwMetaDataCache mdc)
		{
			if (this.Depth == 0)
				Debug.WriteLine("");
			for (int i = 0; i < this.Depth; ++i)
				Debug.Write("    ");
			if (Source != 0)
			{
				Debug.WriteLine("[" + this.Depth + "]info.Source = " + this.Source + " = " +
				GetFancyFieldName(this.Source, mdc));
			}
			else
			{
				Debug.WriteLine("Root (target) class: " + mdc.GetClassName(m_targetClass));
			}

			for (int i = 0; i < this.AtomicFields.Count; ++i)
			{
				for (int j = 0; j < this.Depth; ++j)
					Debug.Write("    ");
				Debug.WriteLine("    Atomic[" + i + "] flid = " + this.AtomicFields[i].flid + "(" +
					GetFancyFieldName(this.AtomicFields[i].flid, mdc) + "); ws = " + this.AtomicFields[i].ws);
			}
			for (int i = 0; i < this.SeqFields.Count; ++i)
				this.SeqFields[i].DumpFieldInfo(mdc);
		}
Ejemplo n.º 55
0
		static internal bool IsMultilingual(int flid, IFwMetaDataCache mdc)
		{
			switch ((CellarPropertyType)(mdc.GetFieldType(flid) & (int)CellarPropertyTypeFilter.VirtualMask))
			{
			case CellarPropertyType.MultiString:
			case CellarPropertyType.MultiUnicode:
				return true;
			default:
				return false;
			}
		}
Ejemplo n.º 56
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			base.Dispose(disposing);

			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
				if (m_xmlVc != null)
					m_xmlVc.Dispose();
			}
			m_xmlVc = null;
			m_stringTable = null;
			m_mdc = null;
			m_sXmlSpec = null;
			m_docSpec = null;
			m_xnSpec = null;
		}
Ejemplo n.º 57
0
		private string GetFancyFieldName(int flid, IFwMetaDataCache mdc)
		{
			string f = mdc.GetFieldName(flid);
			string c = mdc.GetOwnClsName(flid);
			return c + '_' + f;
		}
Ejemplo n.º 58
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Return true if this is a property the mdc can't tell us about.
		/// This is overridden in RootSite, where we can cast it to IFwMetaDataCacheManaged and really find out.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override bool IsUnknownProp(IFwMetaDataCache mdc, int tag)
		{
			return !(mdc is IFwMetaDataCacheManaged && ((IFwMetaDataCacheManaged)mdc).FieldExists(tag));
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes the WritingSystemPropertiesDialog class. Clients written in .Net with an FdoCache
		/// should use the version of the constructor that accepts an FdoCache. COM clients that
		/// do not have an FdoCache should use the default constructor and then call this method
		/// to initialize the object.
		/// </summary>
		/// <param name="ode"></param>
		/// <param name="mdc"></param>
		/// <param name="oleDbAccess"></param>
		/// <param name="helpTopicProvider">IHelpTopicProvider object used to get help
		/// information</param>
		/// <param name="stylesheet">Used for the FwTextBox</param>
		/// ------------------------------------------------------------------------------------
		public void Initialize(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			IHelpTopicProvider helpTopicProvider, IVwStylesheet stylesheet)
		{
			CheckDisposed();

			FdoCache cache = new FdoCache(ode, mdc, oleDbAccess);
			m_cacheMadeLocally = true;
			Initialize(cache, helpTopicProvider, stylesheet);
		}
Ejemplo n.º 60
0
		static internal int GetCustomFieldFlid(XmlNode caller, IFwMetaDataCache mdc, ICmObject obj)
		{
			string fieldName = XmlUtils.GetManditoryAttributeValue(caller, "param");
			// It would be nice to avoid all the possible throws for invalid fields, but hard
			// to achieve in a static method.
			try
			{
				int flid = mdc.GetFieldId2(obj.ClassID, fieldName, true);
				return flid;
			}
			catch
			{
				return 0;
			}
		}