/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the specified entry using the application with the lexical data. /// </summary> /// ------------------------------------------------------------------------------------ public void ShowEntry(string entry, EntryType entryType) { LexicalProviderManager.ResetLexicalProviderTimer(); Logger.WriteEvent("Showing entry from external application for the " + entryType + " " + entry); if (entryType != EntryType.Word) { throw new ArgumentException("Unknown entry type specified."); } // An asynchronous call is necessary because the WCF server (FieldWorks) will not // respond until this method returns. This also allows methods that show dialogs on the // WCF server to not be OneWay. (Otherwise, time-out exceptions occur.) FieldWorks.ThreadHelper.InvokeAsync(() => { ITsString tss = TsStringUtils.MakeString(entry, FieldWorks.Cache.DefaultVernWs); using (Mediator mediator = new Mediator()) using (PropertyTable propertyTable = new PropertyTable(mediator)) { propertyTable.SetProperty("HelpTopicProvider", FieldWorks.GetHelpTopicProvider(), true); propertyTable.SetPropertyPersistence("HelpTopicProvider", false); var flexApp = FieldWorks.GetOrCreateFlexApp(); propertyTable.SetProperty("FeedbackInfoProvider", flexApp, true); propertyTable.SetPropertyPersistence("FeedbackInfoProvider", false); propertyTable.SetProperty("App", flexApp, true); LexEntryUi.DisplayEntry(FieldWorks.Cache, mediator, propertyTable, propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider"), "UserHelpFile", tss, null); } }); }
public static int Main(string[] rgArgs) { using (FieldWorks.StartFwApp(FwUtils.ksTeAbbrev, rgArgs)) { return(0); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the related words to the specified entry using the application with the /// lexical data. /// </summary> /// ------------------------------------------------------------------------------------ public void ShowRelatedWords(string entry, EntryType entryType) { LexicalProviderManager.ResetLexicalProviderTimer(); Logger.WriteEvent("Showing related word from external application for the " + entryType + " " + entry); if (entryType != EntryType.Word) { throw new ArgumentException("Unknown entry type specified."); } // An asynchronous call is necessary because the WCF server (FieldWorks) will not // respond until this method returns. This also allows methods that show dialogs on the // WCF server to not be OneWay. (Otherwise, time-out exceptions occur.) FieldWorks.ThreadHelper.InvokeAsync(() => { ITsString tss = TsStringUtils.MakeTss(entry, FieldWorks.Cache.DefaultVernWs); Mediator mediator = new Mediator(); mediator.HelpTopicProvider = FieldWorks.GetHelpTopicProvider(FwUtils.ksFlexAbbrev); mediator.FeedbackInfoProvider = FieldWorks.GetOrCreateFlexApp(); mediator.PropertyTable.SetProperty("App", FieldWorks.GetOrCreateFlexApp()); LexEntryUi.DisplayRelatedEntries(FieldWorks.Cache, mediator, mediator.HelpTopicProvider, "UserHelpFile", tss); }); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Opens a new main window for the specified application. /// </summary> /// <param name="app">The application.</param> /// <param name="wndToCopyFrom">The window to copy information from (optional).</param> /// ------------------------------------------------------------------------------------ public void OpenNewWindowForApp(FwApp app, Form wndToCopyFrom) { if (!FieldWorks.CreateAndInitNewMainWindow(app, false, wndToCopyFrom, false)) { Debug.Fail("New main window was not created correctly!"); } }
public static int Main(string[] rgArgs) { using (FieldWorks.StartFwApp(rgArgs)) { return(0); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Waits for other app. /// </summary> /// ------------------------------------------------------------------------------------ public void WaitForOtherApp() { Text = FwUtils.ksSuiteName; switch (m_whatToWaitFor) { case WaitFor.WindowToActivate: m_lblMessage.Text = string.Format(Properties.Resources.kstidThisApplicationIsBusy, m_appToStart.ApplicationName, m_appToStart.Cache.ProjectId.Name); break; case WaitFor.OtherBusyApp: m_lblMessage.Text = string.Format(Properties.Resources.kstidOtherApplicationBusy, m_appToStart.ApplicationName, m_appToStart.Cache.ProjectId.Name, m_appToWaitFor.ApplicationName); break; case WaitFor.ModalDialogsToClose: m_lblMessage.Text = string.Format(Properties.Resources.kstidOtherApplicationHasDialog, m_appToStart.ApplicationName, m_appToStart.Cache.ProjectId.Name, m_appToWaitFor.ApplicationName); break; } Show(); Activate(); bool readyToRoll = false; do { Application.DoEvents(); Thread.Sleep(333); if (m_fCancelPressed) { break; } switch (m_whatToWaitFor) { case WaitFor.WindowToActivate: readyToRoll = (m_appToStart.MainWindows.Count > 0); break; case WaitFor.OtherBusyApp: readyToRoll = !DataUpdateMonitor.IsUpdateInProgress(); break; case WaitFor.ModalDialogsToClose: readyToRoll = !m_appToWaitFor.IsModalDialogOpen; break; } }while (!readyToRoll); Close(); if (readyToRoll) { FieldWorks.KickOffAppFromOtherProcess(m_args); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determines whether [is same project] [the specified name]. /// </summary> /// ------------------------------------------------------------------------------------ public bool ShouldWait(string name, string server) { var matchStatus = FieldWorks.GetProjectMatchStatus(new ProjectId(name, server)); return(matchStatus == ProjectMatch.DontKnowYet || matchStatus == ProjectMatch.WaitingForUserOrOtherFw || matchStatus == ProjectMatch.SingleProcessMode); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Tick event of the s_timeSinceLexicalProviderUsed control. /// </summary> /// <param name="sender">The source of the event.</param> /// ------------------------------------------------------------------------------------ private static void s_timeSinceLexicalProviderUsed_Tick(object sender) { FieldWorks.InAppServerMode = false; if (FieldWorks.ProcessCanBeAutoShutDown) { FieldWorks.GracefullyShutDown(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Lets the user create a new language project and opens it. If the project is already /// open in a FieldWorks process, then the request is sent to the running FieldWorks /// process and a new window is opened for that project. Otherwise a new FieldWorks /// process is started to handle the new project. /// </summary> /// <param name="app">The application.</param> /// <param name="dialogOwner">The owner for the dialog.</param> /// ------------------------------------------------------------------------------------ public void CreateNewProject(FwApp app, Form dialogOwner) { ProjectId newProject = FieldWorks.CreateNewProject(dialogOwner, app, app); if (newProject != null && !FieldWorks.OpenNewProject(newProject, app.ApplicationName)) { Debug.Fail("Failed to open the new project"); } }
public void EnsureValidLinkedFilesFolderCore_IfUsingDefaultDir_CreatesDirIfNotExist() { EnsureValidLinkedFilesFolderCore_TestHelper(defaultFolder => { var configuredFolder = defaultFolder; Assert.That(FileUtils.DirectoryExists(configuredFolder), Is.False, "Unit test not testing what it's supposed to"); FieldWorks.EnsureValidLinkedFilesFolderCore(configuredFolder, defaultFolder); Assert.That(FileUtils.DirectoryExists(configuredFolder), Is.True, "Should have created directory"); }); }
private bool InternalInitialize(string name, string server, bool loadOnlyWs, int timeToWaitForProcessStart, int timeToWaitForLoadingData) { bool foundFwProcess = false; bool newProcessStarted = false; Process newFwInstance = null; var start = DateTime.Now; var timeToWaitTotalMillis = timeToWaitForLoadingData + timeToWaitForProcessStart; try { do { FieldWorks.RunOnRemoteClients(FieldWorks.kPaRemoteRequest, requestor => { return(LoadFwDataForPa((PaRemoteRequest)requestor, name, server, loadOnlyWs, timeToWaitForLoadingData, newProcessStarted, out foundFwProcess)); }); if (foundFwProcess) { return(true); } if (!newProcessStarted) { newProcessStarted = true; newFwInstance = FieldWorks.OpenProjectWithNewProcess(null, name, server, FwUtils.ksFlexAbbrev, "-" + FwAppArgs.kNoUserInterface); // TODO-Linux: WaitForInputIdle isn't fully implemented on Linux. if (!newFwInstance.WaitForInputIdle(timeToWaitForProcessStart)) { return(false); } } } while ((DateTime.Now - start).TotalMilliseconds <= timeToWaitTotalMillis); } finally { if (newFwInstance != null) { if (!newFwInstance.HasExited) { newFwInstance.Kill(); } newFwInstance.Dispose(); } Debug.WriteLine((DateTime.Now - start).TotalMilliseconds); } // this line is reached only on startup timeout. return(false); }
public void EnsureValidLinkedFilesFolderCore_IfUsingDefaultDirAndItExists_DoesntCrashOrAnything() { EnsureValidLinkedFilesFolderCore_TestHelper(defaultFolder => { // Make default linked files directory already exist FileUtils.EnsureDirectoryExists(defaultFolder); // Not crash or anything Assert.DoesNotThrow(() => FieldWorks.EnsureValidLinkedFilesFolderCore(defaultFolder, defaultFolder)); }); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Lets the user chooses a language project and opens it. If the project is already /// open in a FieldWorks process, then the request is sent to the running FieldWorks /// process and a new window is opened for that project. Otherwise a new FieldWorks /// process is started to handle the project request. /// </summary> /// <param name="app">The application.</param> /// <param name="dialogOwner">The owner for the dialog.</param> /// ------------------------------------------------------------------------------------ public void ChooseLangProject(FwApp app, Form dialogOwner) { Debug.Assert(dialogOwner is IFwMainWnd, "OpenExistingProject cannot use this window for copying"); ProjectId openedProject = FieldWorks.ChooseLangProject(dialogOwner, app); if (openedProject != null && !FieldWorks.OpenExistingProject(openedProject, app, dialogOwner)) { Debug.Fail("Failed to open the project specified!"); } }
public void EnsureValidLinkedFilesFolderCore_NonDefaultLocation_NotCreateNonExistentDir() { EnsureValidLinkedFilesFolderCore_TestHelper(defaultFolder => { var configuredFolder = FileUtils.ChangePathToPlatform("/nondefaultAndNonexistentPath"); Assert.That(defaultFolder, Is.Not.EqualTo(configuredFolder), "Unit test not set up right"); Assert.That(FileUtils.DirectoryExists(configuredFolder), Is.False, "Unit test not testing what it's supposed to"); FieldWorks.EnsureValidLinkedFilesFolderCore(configuredFolder, defaultFolder); Assert.That(FileUtils.DirectoryExists(configuredFolder), Is.False, "Shouldn't have just made the nondefault directory"); }); }
/// ------------------------------------------------------------------------------------ /// <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 }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks to see whether this instance is connected to the requested project. If so, /// attempts to do a restore using the specified restore settings. /// </summary> /// <param name="restoreSettings">The restore settings.</param> /// <returns>True if the project belonged to this instance and the restore was /// successful, false otherwise.</returns> /// ------------------------------------------------------------------------------------ public bool HandleRestoreProjectRequest(FwRestoreProjectSettings restoreSettings) { ProjectMatch isMyProject = FieldWorks.GetProjectMatchStatus( new ProjectId(restoreSettings.Settings.FullProjectPath)); if (isMyProject != ProjectMatch.ItsMyProject) { return(false); } FieldWorks.HandleRestoreRequest(restoreSettings); return(true); }
/// ------------------------------------------------------------------------------------ /// <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); }
public void EnsureValidLinkedFilesFolderCore_NonDefaultLocationAndExists_DoesntCrashOrAnything() { EnsureValidLinkedFilesFolderCore_TestHelper(defaultFolder => { var configuredFolder = FileUtils.ChangePathToPlatform("/nondefaultPath"); // Make linked files directory already exist FileUtils.EnsureDirectoryExists(configuredFolder); Assert.That(defaultFolder, Is.Not.EqualTo(configuredFolder), "Unit test not set up right"); Assert.That(FileUtils.DirectoryExists(configuredFolder), Is.True, "Unit test not testing what it's supposed to"); // Not crash or anything FieldWorks.EnsureValidLinkedFilesFolderCore(configuredFolder, defaultFolder); }); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shut down the specified application, which will be disposed of immediately. /// If no other applications are running, then FieldWorks will also be shut down. /// </summary> /// <param name="app">The application to shut down.</param> /// ------------------------------------------------------------------------------------ public void ShutdownApp(FwApp app) { FieldWorks.ShutdownApp(app, true); }
/// <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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Rename the project used by this FieldWorks to the specified new name. /// </summary> /// <returns>True if the rename was successful, false otherwise</returns> /// ------------------------------------------------------------------------------------ public bool RenameProject(string newName, FwApp app) { return(FieldWorks.RenameProject(newName, app)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Restore a project. /// </summary> /// <param name="fwApp">The FieldWorks application.</param> /// <param name="dialogOwner">The dialog owner.</param> /// ------------------------------------------------------------------------------------ public void FileProjectSharingLocation(FwApp fwApp, Form dialogOwner) { FieldWorks.FileProjectSharingLocation(dialogOwner, fwApp); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Restore a project. /// </summary> /// <param name="fwApp">The FieldWorks application.</param> /// <param name="dialogOwner">The dialog owner.</param> /// ------------------------------------------------------------------------------------ public void RestoreProject(FwApp fwApp, Form dialogOwner) { FieldWorks.RestoreProject(dialogOwner, fwApp); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Lets the user backup any FW databases that are not currently open /// </summary> /// <param name="app">The application.</param> /// <param name="dialogOwner">The owner of the dialog</param> /// <returns>The path to the backup file, or <c>null</c> if the user cancels the /// backup</returns> /// ------------------------------------------------------------------------------------ public string BackupProject(FwApp app, Form dialogOwner) { return(FieldWorks.BackupProject(dialogOwner, app)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Lets the user delete any FW databases that are not currently open /// </summary> /// <param name="app">The application.</param> /// <param name="dialogOwner">The owner of the dialog</param> /// ------------------------------------------------------------------------------------ public void DeleteProject(FwApp app, Form dialogOwner) { FieldWorks.DeleteProject(dialogOwner, app); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle an external request to close all main windows. /// </summary> /// <returns>false because we'll want every process to do this</returns> /// ------------------------------------------------------------------------------------ public bool CloseAllMainWindows() { FieldWorks.CloseAllMainWindows(); return(false); }
/// ------------------------------------------------------------------------------------ public bool IsMyProject(string name, string server) { var matchStatus = FieldWorks.GetProjectMatchStatus(new ProjectId(name, server)); return(matchStatus == ProjectMatch.ItsMyProject); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Lets the user backup any FW databases that are not currently open /// </summary> /// <param name="app">The application.</param> /// <param name="dialogOwner">The owner of the dialog</param> /// ------------------------------------------------------------------------------------ public void BackupProject(FwApp app, Form dialogOwner) { FieldWorks.BackupProject(dialogOwner, app); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Archive selected project files using RAMP /// </summary> /// <param name="fwApp">The FieldWorks application</param> /// <param name="dialogOwner">The owner of the dialog</param> /// <returns>The list of the files to archive, or <c>null</c> if the user cancels the /// archive dialog</returns> /// ------------------------------------------------------------------------------------ public List <string> ArchiveProjectWithRamp(FwApp fwApp, Form dialogOwner) { return(FieldWorks.ArchiveProjectWithRamp(dialogOwner, fwApp)); }