Esempio n. 1
0
 private bool SameDatabase(FwAppArgs fwargs, FdoCache cache)
 {
     return(fwargs.Database == "this$" ||
            fwargs.Database.ToLowerInvariant() == cache.ProjectId.Name.ToLowerInvariant() ||
            fwargs.Database.ToLowerInvariant() == cache.ProjectId.Path.ToLowerInvariant() ||
            Path.GetFileName(fwargs.Database).ToLowerInvariant() == cache.ProjectId.Name.ToLowerInvariant());
 }
Esempio n. 2
0
        /// <summary>
        /// Builds a context descriptor with the given parameters that will provide a url link to the correct area in FLEx.
        /// </summary>
        internal static ContextDescriptor GenerateContextDescriptor(string filePath, string guid, string label)
        {
            var appId         = "FLEx";
            var directory     = Path.GetDirectoryName(filePath);
            var lastDirectory = Path.GetFileName(directory);

            if (lastDirectory == "Scripture")
            {
                appId = "TE";
            }
            // figure out here which we need.
            var fwAppArgs = new FwAppArgs(appId, "current", "", "default", guid);

            // Add the "label" information which the Chorus Notes browser extracts to identify the object in the UI.
            // This is just for a label and we can't have & or = in the value. So replace them if they occur.
            fwAppArgs.AddProperty("label", label.Replace("&", " and ").Replace("=", " equals "));
            // The FwUrl has all the query part encoded.
            // Chorus needs it unencoded so it can extract the label.
            var fwUrl      = fwAppArgs.ToString();
            var hostLength = fwUrl.IndexOf("?", StringComparison.Ordinal);
            var host       = fwUrl.Substring(0, hostLength);
            var query      = HttpUtilityFromMono.UrlDecode(fwUrl.Substring(hostLength + 1));
            var url        = host + "?" + query;

            return(new ContextDescriptor(label, url));
        }
Esempio n. 3
0
        /// <summary>
        /// Handle the specified link if it is local.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public bool OnHandleLocalHotlink(object source)
        {
            LocalLinkArgs args = source as LocalLinkArgs;

            if (args == null)
            {
                return(true);                // we can't handle it, but probably no one else can either. Maybe should crash?
            }
            var url = args.Link;

            if (!url.StartsWith(FwLinkArgs.kFwUrlPrefix))
            {
                return(true);                // we can't handle it, but no other colleague can either. Needs to launch whatever can (see VwBaseVc.DoHotLinkAction).
            }
            try
            {
                var      fwargs = new FwAppArgs(new[] { url });
                FdoCache cache  = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                if (SameServer(fwargs, cache) && SameDatabase(fwargs, cache))
                {
                    OnFollowLink(fwargs);
                    args.LinkHandledLocally = true;
                }
            }
            catch (Exception)
            {
                // Something went wrong, probably its not a kind of link we understand.
            }
            return(true);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shows an instance of this dialog on a separate thread.
        /// </summary>
        /// <param name="args">The application arguments</param>
        /// <param name="whatToWaitFor">The condition we're waiting for.</param>
        /// <param name="appToStart">The application to start.</param>
        /// <param name="appToWaitFor">The application to wait for (null if waiting for
        /// WindowToActivate).</param>
        /// ------------------------------------------------------------------------------------
        internal static void ShowOnSeparateThread(FwAppArgs args, WaitFor whatToWaitFor,
                                                  FwApp appToStart, FwApp appToWaitFor)
        {
            if (whatToWaitFor != WaitFor.WindowToActivate && appToWaitFor == null)
            {
                throw new ArgumentNullException("appToWaitFor");
            }
            if (appToStart == null)
            {
                throw new ArgumentNullException("appToStart");
            }

            ApplicationBusyDialog dlg = new ApplicationBusyDialog();

            dlg.m_whatToWaitFor = whatToWaitFor;
            dlg.m_args          = args;
            dlg.m_appToStart    = appToStart;
            dlg.m_appToWaitFor  = appToWaitFor;
            Thread thread = new Thread(dlg.WaitForOtherApp);

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Name             = "WaitForOtherBusyApp";
            thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
            thread.Start();
        }
Esempio n. 5
0
        public bool OnViewIncorrectWords(object argument)
        {
            FwLinkArgs link = new FwAppArgs(FwUtils.ksFlexAppName, Cache.ProjectId.Handle,
                                            Cache.ProjectId.ServerName, "Analyses", ActiveWordform(Cache, m_mediator));
            List <Property> additionalProps = link.PropertyTableEntries;

            additionalProps.Add(new Property("SuspendLoadListUntilOnChangeFilter", link.ToolName));
            additionalProps.Add(new Property("LinkSetupInfo", "TeCorrectSpelling"));
            m_mediator.PostMessage("FollowLink", link);
            return(true);
        }
Esempio n. 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks to see whether this instance is connected to the requested project. If so,
        /// starts up the requested app or activates a main window for that app if already
        /// running.
        /// </summary>
        /// <param name="projectId">The requested project ID.</param>
        /// <param name="args">The application arguments</param>
        /// <returns>The result of checking to see if the specified project matches the
        /// project this instance is running</returns>
        /// ------------------------------------------------------------------------------------
        public ProjectMatch HandleOpenProjectRequest(ProjectId projectId, FwAppArgs args)
        {
            ProjectMatch isMyProject = FieldWorks.GetProjectMatchStatus(projectId);

            if (isMyProject != ProjectMatch.ItsMyProject)
            {
                return(isMyProject);
            }

            FieldWorks.KickOffAppFromOtherProcess(args);
            return(ProjectMatch.ItsMyProject);            // The request has been handled at this point
        }
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public bool OnCopyLocationAsHyperlink(object unused)
 {
     CheckDisposed();
     if (m_currentContext != null)
     {
         FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
         var      args  = new FwAppArgs(FwUtils.ksFlexAbbrev, cache.ProjectId.Handle,
                                        cache.ProjectId.ServerName, m_currentContext.ToolName, m_currentContext.TargetGuid);
         ClipboardUtils.SetDataObject(args.ToString(), true);
     }
     return(true);
 }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public bool OnCopyLocationAsHyperlink(object unused)
 {
     CheckDisposed();
     if (m_currentContext != null)
     {
         LcmCache cache = m_propertyTable.GetValue <LcmCache>("cache");
         var      args  = new FwAppArgs(cache.ProjectId.Handle,
                                        m_currentContext.ToolName, m_currentContext.TargetGuid);
         ClipboardUtils.SetDataObject(args.ToString(), true);
     }
     return(true);
 }
Esempio n. 9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the specified link request.
        /// </summary>
        /// <param name="link">The link.</param>
        /// <returns>True if the link was successfully handled, false otherwise.</returns>
        /// ------------------------------------------------------------------------------------
        public bool HandleLinkRequest(FwAppArgs link)
        {
            ProjectMatch isMyProject = FieldWorks.GetProjectMatchStatus(
                new ProjectId(link.DatabaseType, link.Database));

            if (isMyProject != ProjectMatch.ItsMyProject)
            {
                return(false);
            }

            FieldWorks.FollowLink(link);
            return(true);
        }
Esempio n. 10
0
        /// <summary>
        /// Called by reflection to implement the command.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public bool OnEditSpellingStatus(object argument)
        {
            // Without checking both the SpellingStatus and (virtual) FullConcordanceCount
            // fields for the ActiveWordform() result, it's too likely that the user
            // will get a puzzling "Target not found" message popping up.  See LT-8717.
            FwLinkArgs link = new FwAppArgs(FwUtils.ksFlexAppName, Cache.ProjectId.Handle,
                                            Cache.ProjectId.ServerName, "toolBulkEditWordforms", Guid.Empty);
            List <Property> additionalProps = link.PropertyTableEntries;

            additionalProps.Add(new Property("SuspendLoadListUntilOnChangeFilter", link.ToolName));
            additionalProps.Add(new Property("LinkSetupInfo", "TeReviewUndecidedSpelling"));
            m_mediator.PostMessage("FollowLink", link);
            return(true);
        }
Esempio n. 11
0
 private bool SameServer(FwAppArgs fwargs, FdoCache cache)
 {
     if (String.IsNullOrEmpty(fwargs.Server) && String.IsNullOrEmpty(cache.ProjectId.ServerName))
     {
         return(true);
     }
     if (String.IsNullOrEmpty(fwargs.Server) && fwargs.Database == "this$")
     {
         return(true);
     }
     if (String.IsNullOrEmpty(fwargs.Server) || String.IsNullOrEmpty(cache.ProjectId.ServerName))
     {
         return(false);
     }
     return(fwargs.Server.ToLowerInvariant() == cache.ProjectId.ServerName.ToLowerInvariant());
 }
Esempio n. 12
0
        private static FwXWindow RefreshCacheWindowAndAll(LexTextApp app, string fullProjectFileName)
        {
            var manager      = app.FwManager;
            var appArgs      = new FwAppArgs(fullProjectFileName);
            var newAppWindow =
                (FwXWindow)manager.ReopenProject(manager.Cache.ProjectId.Name, appArgs).ActiveMainWindow;

            if (IsVernacularSpellingEnabled(newAppWindow.Mediator))
            {
                WfiWordformServices.ConformSpellingDictToWordforms(newAppWindow.Cache);
            }
            //clear out any sort cache files (or whatever else might mess us up) and then refresh
            newAppWindow.ClearInvalidatedStoredData();
            newAppWindow.RefreshDisplay();
            return(newAppWindow);
        }
Esempio n. 13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Links to lexicon.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void LinkToLexicon()
        {
            CheckDisposed();
            int hvo = m_hvoSelected;

            if (hvo == 0 && m_rghvo != null && m_rghvo.Count > 0)
            {
                hvo = m_rghvo[0];
            }
            // REVIEW: THIS SHOULD NEVER HAPPEN, BUT IF IT DOES, SHOULD WE TELL THE USER ANYTHING?
            if (hvo == 0)
            {
                return;
            }
            ICmObject cmo  = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo);
            FwAppArgs link = new FwAppArgs(m_cache.ProjectId.Handle, "lexiconEdit", cmo.Guid);

            Debug.Assert(m_mediator != null, "The program must pass in a mediator to follow a link in the same application!");
            IApp app = m_propertyTable.GetValue <IApp>("App");

            app.HandleOutgoingLink(link);
        }
Esempio n. 14
0
 public MockFwXApp(IFieldWorksManager fwManager, IHelpTopicProvider helpTopicProvider, FwAppArgs appArgs)
     : base(fwManager, helpTopicProvider, appArgs)
 {
 }
Esempio n. 15
0
 /// <summary>
 /// Reopens the given FLEx project. This may be necessary if some external process modified the project data.
 /// Currently used when FLExBridge modifies our project during a Send/Receive
 /// </summary>
 /// <param name="project">The project name to re-open</param>
 /// <param name="app"></param>
 public FwApp ReopenProject(string project, FwAppArgs app)
 {
     throw new NotImplementedException();
 }
Esempio n. 16
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Handles a link request. This is expected to handle determining the correct
 /// application to start up on the correct project and passing the link to any newly
 /// started application.
 /// </summary>
 /// <param name="link">The link.</param>
 /// ------------------------------------------------------------------------------------
 public void HandleLinkRequest(FwAppArgs link)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Reopens the given FLEx project. This may be necessary if some external process modified the project data.
 /// Currently used when FLExBridge modifies our project during a Send/Receive
 /// </summary>
 /// <param name="project">The project name to re-open</param>
 /// <param name="app"></param>
 public FwApp ReopenProject(string project, FwAppArgs app)
 {
     return(FieldWorks.ReopenProject(project, app));
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Handles a link request. This is expected to handle determining the correct
 /// application to start up on the correct project and passing the link to any newly
 /// started application.
 /// </summary>
 /// <param name="link">The link.</param>
 /// ------------------------------------------------------------------------------------
 public void HandleLinkRequest(FwAppArgs link)
 {
     FieldWorks.HandleLinkRequest(link);
 }
Esempio n. 19
0
 public void HandleOutgoingLink(FwAppArgs link)
 {
     throw new NotImplementedException();
 }
Esempio n. 20
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="fwManager">The FieldWorks manager for dealing with FieldWorks-level
 /// stuff.</param>
 /// <param name="helpTopicProvider">An application-specific help topic provider.</param>
 /// <param name="appArgs">The application arguments.</param>
 /// ------------------------------------------------------------------------------------
 public FwXApp(IFieldWorksManager fwManager, IHelpTopicProvider helpTopicProvider,
               FwAppArgs appArgs) : base(fwManager, helpTopicProvider)
 {
     m_appArgs = appArgs;
 }
Esempio n. 21
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// TeApp Constructor takes command line arguments
 /// </summary>
 /// <param name="fwManager">The FieldWorks manager for dealing with FieldWorks-level
 /// stuff.</param>
 /// <param name="helpTopicProvider">An application-specific help topic provider.</param>
 /// <param name="appArgs"></param>
 /// ------------------------------------------------------------------------------------
 public TeApp(IFieldWorksManager fwManager, IHelpTopicProvider helpTopicProvider, FwAppArgs appArgs)
     : base(fwManager, helpTopicProvider)
 {
     Options.AddErrorReportingInfo();
     m_appArgs = appArgs;
 }