Пример #1
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);
        }
Пример #2
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);
		}
Пример #3
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;
     }
 }
Пример #4
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;
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
Пример #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This method should be called after creating, but prior to calling DoModeless. This
		/// overload is meant to be called from unmanaged code.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="ode"></param>
		/// <param name="oleDbAccess"></param>
		/// <param name="rootSite">view</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="findPattern">The find/replace pattern.</param>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// ------------------------------------------------------------------------------------
		public void SetOwner(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			IVwRootSite rootSite, IntPtr hwnd, IVwPattern findPattern)
		{
			CheckDisposed();

			SetOwner(new FdoCache(ode, mdc, oleDbAccess), rootSite, hwnd, findPattern);
		}
Пример #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the initial values for the dialog controls, prior to displaying the dialog.
		/// This method should be called after creating, but prior to calling DoModeless. This
		/// overload is meant to be called from unmanaged code.
		/// </summary>
		/// <param name="mdc"></param>
		/// <param name="ode"></param>
		/// <param name="oleDbAccess"></param>
		/// <param name="vwPattern">Find/replace values</param>
		/// <param name="rootSite">view</param>
		/// <param name="fReplace"><c>true</c> to initially display replace dialog page</param>
		/// <param name="fOverlays">ignored for now</param>
		/// <param name="sUserWs">UI writing system</param>
		/// <param name="hwnd">The window handle of the main window that owns the rootsite
		/// </param>
		/// <param name="tool">The app (needed to be able to disable all main windows)</param>
		/// <param name="helpTopicProvider">help topic provider allows the dialog box class
		/// to specify the appropriate help topic path for this dialog
		/// </param>
		/// <param name="wsEdit">writing system for the find and replace edit boxes</param>
		/// <returns>true if the dialog was initialized properly, otherwise false.
		/// False indicates some problem and the find/replace dialog should not be
		/// shown at this time.</returns>
		/// <remarks>ENHANCE JohnT: it may need more arguments, for example, the name of the
		/// kind of object we can restrict the search to, a list of fields.</remarks>
		/// ------------------------------------------------------------------------------------
		public bool SetDialogValues(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			IVwPattern vwPattern, IVwRootSite rootSite, bool fReplace, bool fOverlays,
			string sUserWs, IntPtr hwnd, IFwTool tool, IHelpTopicProvider helpTopicProvider,
			int wsEdit)
		{
			CheckDisposed();

			m_cacheMadeLocally = true;
			return SetDialogValues(new FdoCache(ode, mdc, oleDbAccess), vwPattern, rootSite,
				fReplace, fOverlays, sUserWs, hwnd, tool, helpTopicProvider, wsEdit);
		}
Пример #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the error annotation to the database.
        /// </summary>
        /// <param name="citedText">The cited text.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="length">The length.</param>
        /// <param name="checkId">The Scripture error checking id.</param>
        /// <param name="firstToken">The first token.</param>
        /// <param name="lastToken">The last token.</param>
        /// <param name="formattedMsg">The formatted error message.</param>
        /// ------------------------------------------------------------------------------------
        private void AddErrorAnnotation(string citedText, int offset, int length, Guid checkId,
                                        ScrCheckingToken firstToken, ScrCheckingToken lastToken, string formattedMsg)
        {
            ScrBookAnnotations annotations =
                (ScrBookAnnotations)m_scr.BookAnnotationsOS[firstToken.StartRef.Book - 1];

            StTxtParaBldr quote      = SetCitedText(citedText, firstToken.Ws);
            StTxtParaBldr discussion = SetErrorMessage(formattedMsg);

            bool        fNewTransaction = false;
            string      sSavePointName  = string.Empty;
            IOleDbEncap dbAccess        = m_cache.DatabaseAccessor;

            if (dbAccess != null)
            {
                // Open a transaction or set a save point in case there is a problem with the DB server.
                // If there is a problem adding the annotation or setting the type, this
                // transaction will be rolled back rather than not leaving the annotation
                // only partly initialized.
                if (!dbAccess.IsTransactionOpen())
                {
                    dbAccess.BeginTrans();
                    fNewTransaction = true;
                }
                else
                {
                    dbAccess.SetSavePoint(out sSavePointName);
                }
            }

            try
            {
                IScrScriptureNote note =
                    annotations.InsertErrorAnnotation(firstToken.StartRef, lastToken.EndRef,
                                                      firstToken.Object, lastToken.Object, checkId, quote, discussion);

                note.BeginOffset = firstToken.ParaOffset + offset;
                note.EndOffset   = note.BeginOffset + length;
                note.Flid        = firstToken.Flid;
                // REVIEW: Should we even be setting the WsSelector for anything except picture captions?
                note.WsSelector = m_cache.DefaultVernWs;
            }
            catch
            {
                // Rollback inserted note
                Debug.Assert(dbAccess != null);
                if (dbAccess != null)
                {
                    if (fNewTransaction)
                    {
                        dbAccess.RollbackTrans();
                    }
                    else
                    {
                        dbAccess.RollbackSavePoint(sSavePointName);
                    }
                }
                throw;
            }
            if (fNewTransaction)
            {
                dbAccess.CommitTrans();
            }
        }
Пример #9
0
		/// <summary>Reload MetaDataCache.</summary>
		/// <param name='ode'>Database connection</param>
		/// <param name='keepVirtuals'>True to keep virtual data field information, otherwise false.</param>
		/// <remarks>
		/// This class does not support database access.
		/// </remarks>
		public void Reload(IOleDbEncap ode, bool keepVirtuals)
		{
			throw new NotImplementedException("'Reload will not be implemented, because this class does not support database access.");
		}
Пример #10
0
		/// <summary>Initialize using a database.</summary>
		/// <param name='ode'>Database connection</param>
		/// <remarks>
		/// This class does not support database access.
		/// </remarks>
		public void Init(IOleDbEncap ode)
		{
			throw new NotImplementedException("'Init' will not be implemented, because this class does not support database access.");
		}
Пример #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes the FwUserProperties 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 consructor and then call this method
		/// to initialize the object.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void Initialize(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			Feature[] features)
		{
			CheckDisposed();

			m_Cache = new FdoCache(ode, mdc, oleDbAccess);
			m_cacheMadeLocally = true;
			m_Features = features;

			Initialize();
		}
Пример #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes the FwProjProperties 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="tool">IFwTool object used to open/close application window</param>
		/// <param name="helpTopicProvider">IHelpTopicProvider object used to get help
		/// information</param>
		/// <param name="strmLog">optional log file stream</param>
		/// <param name="hvoProj">Hvo of the Language Project</param>
		/// <param name="hvoRoot">Hvo of the root object</param>
		/// <param name="wsUser">user interface writing system id</param>
		/// <param name="stylesheet">stylesheet for FwTextBox</param>
		/// ------------------------------------------------------------------------------------
		public void Initialize(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			IFwTool tool, IHelpTopicProvider helpTopicProvider, IStream strmLog, int hvoProj,
			int hvoRoot, int wsUser, IVwStylesheet stylesheet)
		{
			CheckDisposed();

			m_cache = new FdoCache(ode, mdc, oleDbAccess);
			m_cacheMadeLocally = true;
			m_tool = tool;
			m_helpTopicProvider = helpTopicProvider;
			m_strmLog = strmLog;
			m_hvoProj = hvoProj;
			m_hvoRoot = hvoRoot;
			m_wsUser = wsUser;
			m_stylesheet = stylesheet;

			Initialize();
		}
Пример #13
0
 /// <summary>Reload MetaDataCache.</summary>
 /// <param name='ode'>Database connection</param>
 /// <param name='keepVirtuals'>True to keep virtual data field information, otherwise false.</param>
 /// <remarks>
 /// This class does not support database access.
 /// </remarks>
 public void Reload(IOleDbEncap ode, bool keepVirtuals)
 {
     throw new NotImplementedException("'Reload will not be implemented, because this class does not support database access.");
 }
Пример #14
0
 /// <summary>Initialize using a database.</summary>
 /// <param name='ode'>Database connection</param>
 /// <remarks>
 /// This class does not support database access.
 /// </remarks>
 public void Init(IOleDbEncap ode)
 {
     throw new NotImplementedException("'Init' will not be implemented, because this class does not support database access.");
 }
Пример #15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:DummyFdoCache"/> class.
		/// </summary>
		/// <param name="ode">The ode.</param>
		/// <param name="mdc">The MDC.</param>
		/// <param name="oleDbAccess">The OLE db access.</param>
		/// <param name="sda">The sda.</param>
		/// ------------------------------------------------------------------------------------
		public DummyFdoCache(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
			ISilDataAccess sda): base(ode, mdc, oleDbAccess, sda)
		{
		}
Пример #16
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DummyFdoCache"/> class.
 /// </summary>
 /// <param name="ode">The ode.</param>
 /// <param name="mdc">The MDC.</param>
 /// <param name="oleDbAccess">The OLE db access.</param>
 /// <param name="sda">The sda.</param>
 /// ------------------------------------------------------------------------------------
 public DummyFdoCache(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess,
                      ISilDataAccess sda) : base(ode, mdc, oleDbAccess, sda)
 {
 }