Пример #1
0
        /// <summary>
        /// Get a new FW project from some Mercurial repository.
        /// The repo may be a lift or full FW repo, but it can be from any source source, as long as the code can create an FW project from it.
        /// </summary>
        /// <returns>Null if the operation was cancelled or otherwise did not work. The full pathname of an fwdata file, if it did work.</returns>
        public static string ObtainProjectFromAnySource(Form parent, IHelpTopicProvider helpTopicProvider, out ObtainedProjectType obtainedProjectType)
        {
            bool   dummy;
            string fwdataFileFullPathname;
            var    success = FLExBridgeHelper.LaunchFieldworksBridge(FwDirectoryFinder.ProjectsDirectory, null, FLExBridgeHelper.Obtain, null,
                                                                     FDOBackendProvider.ModelVersion, "0.13", null, null, out dummy, out fwdataFileFullPathname);

            if (!success)
            {
                ReportDuplicateBridge();
                obtainedProjectType = ObtainedProjectType.None;
                return(null);
            }
            if (string.IsNullOrWhiteSpace(fwdataFileFullPathname))
            {
                obtainedProjectType = ObtainedProjectType.None;
                return(null);                // user canceled.
            }
            obtainedProjectType = ObtainedProjectType.FieldWorks;

            if (fwdataFileFullPathname.EndsWith("lift"))
            {
                fwdataFileFullPathname = CreateProjectFromLift(parent, helpTopicProvider, fwdataFileFullPathname);
                obtainedProjectType    = ObtainedProjectType.Lift;
            }

            EnsureLinkedFoldersExist(fwdataFileFullPathname);

            return(fwdataFileFullPathname);
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="WelcomeToFieldWorksDlg"/> class.
        /// </summary>
        /// <param name="helpTopicProvider">Help topic provider</param>
        /// <param name="exception">Exception that was thrown if the previously requested
        /// project could not be opened.</param>
        /// <param name="showReportingRow">True (usually only on the first run) when we want to show the first-time warning about
        /// sending google analytics information</param>
        /// ------------------------------------------------------------------------------------
        public WelcomeToFieldWorksDlg(IHelpTopicProvider helpTopicProvider, StartupException exception, bool showReportingRow)
        {
            InitializeComponent();
            AccessibleName = GetType().Name;
            var fullAppName = Properties.Resources.kstidFLEx;

            SetCheckboxText = fullAppName;              // Setter uses the app name in a format string.

            if (exception == null || !exception.ReportToUser)
            {
                Text = fullAppName;
                Logger.WriteEvent("Opening 'Welcome to FieldWorks' dialog");
            }
            else
            {
                m_helpTopic = "khtpUnableToOpenProject";
                Text        = Properties.Resources.kstidUnableToOpenProjectCaption;
                m_lblProjectLoadError.Text = exception.Message;
                Logger.WriteEvent("Opening 'Unable to Open Project' dialog");
            }

            if (!showReportingRow)
            {
                reportingInfoLayout.Visible = false;
            }

            m_helpTopicProvider        = helpTopicProvider;
            helpProvider               = new HelpProvider();
            helpProvider.HelpNamespace = FwDirectoryFinder.CodeDirectory + m_helpTopicProvider.GetHelpString("UserHelpFile");
            helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            receiveButton.Enabled = FLExBridgeHelper.IsFlexBridgeInstalled();
        }
        private void OpenBridgeProjectLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            bool   dummy;
            string projectName;
            var    success = FLExBridgeHelper.LaunchFieldworksBridge(DirectoryFinder.ProjectsDirectory, null, FLExBridgeHelper.Obtain, null,
                                                                     out dummy, out projectName);

            if (!success)
            {
                ReportDuplicateBridge();
                Project = "";
            }
            if (string.IsNullOrWhiteSpace(projectName))
            {
                return;                 // user canceled.
            }
            if (projectName.EndsWith("lift"))
            {
                Project = CreateProjectFromLift(projectName);
            }
            else
            {
                Project = projectName;
            }
            Server = null;
            if (String.IsNullOrEmpty(Project))
            {
                return;                 // Don't close the Open project dialog yet (LT-13187)
            }
            // Apparently setting the DialogResult to something other than 'None' is what tells
            // the model dialog that it can close.
            DialogResult = DialogResult.OK;
            OkButtonClick(null, null);
        }
Пример #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ChooseLangProjectDialog"/> class.
 /// Used for the designer
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private ChooseLangProjectDialog()
 {
     InitializeComponent();
     //hide the FLExBridge related link and image if unavailable
     m_linkOpenBridgeProject.Visible = File.Exists(FLExBridgeHelper.FullFieldWorksBridgePath());
     pictureBox1.Visible             = File.Exists(FLExBridgeHelper.FullFieldWorksBridgePath());
 }
Пример #5
0
        /// <summary>
        /// The method/delegate that gets invoked when View->Conflict Report is clicked
        /// via the OnShowConflictReport message
        /// </summary>
        /// <param name="commandObject">Includes the XML command element of the OnShowConflictReport message</param>
        /// <returns>true if the message was handled, false if there was an error or the call was deemed inappropriate.</returns>
        public bool OnShowConflictReport(object commandObject)
        {
            if (IsDb4oProject)
            {
                var dlg = new Db4oSendReceiveDialog();
                if (dlg.ShowDialog() == DialogResult.Abort)
                {
                    // User clicked on link
                    _mediator.SendMessage("FileProjectSharingLocation", null);
                }
                return(true);
            }
            bool   dummy1;
            string dummy2;

            FLExBridgeHelper.FLExJumpUrlChanged += JumpToFlexObject;
            var success = FLExBridgeHelper.LaunchFieldworksBridge(Path.Combine(Cache.ProjectId.ProjectFolder, Cache.ProjectId.Name + FwFileExtensions.ksFwDataXmlFileExtension),
                                                                  Environment.UserName,
                                                                  FLExBridgeHelper.ConflictViewer, null, out dummy1, out dummy2);

            if (!success)
            {
                FLExBridgeHelper.FLExJumpUrlChanged -= JumpToFlexObject;
                ReportDuplicateBridge();
            }
            return(true);
        }
Пример #6
0
        /// <summary>
        /// If the repo exists in the foo\OtherRepositories\LIFT folder, then do nothing.
        /// If the repo or the entire folder structure does not yet exist,
        /// then ask FLEx Bridge to move the previous lift repo to the new home,
        /// it is exists.
        /// </summary>
        /// <remarks>
        /// <para>If the call to FLEx Bridge returns the pathname to the lift file (_liftPathname), we know the move took place,
        /// and we have the lift file that is in the repository. That lift file's name may or may not match the FW project name,
        /// but it ought not matter if it does or does not match.</para>
        /// <para>If the call returned null, we know the move did not take place.
        /// In this case the caller of this method will continue on and probably create a new repository,
        ///	thus doing the equivalent of the original Lift Bridge code where there FLEx user started a S/R lift system.</para>
        /// </remarks>
        /// <returns>'true' if the the move succeeded, or if there was no need to do the move. The caller code will continue its work.
        /// Return 'false', if the calling code should quit its work.</returns>
        private bool MoveOldLiftRepoIfNeeded()
        {
            var projectFolder  = Cache.ProjectId.ProjectFolder;
            var liftProjectDir = GetLiftRepositoryFolderFromFwProjectFolder(projectFolder);

            // It is fine to try the repo move if the liftProjectDir exists, but *only* if it is completely empty.
            // Mercurial can't do a clone into a folder that has contents of any sort.
            if (Directory.Exists(liftProjectDir) && (Directory.GetDirectories(liftProjectDir).Length > 0 || Directory.GetFiles(liftProjectDir).Length > 0))
            {
                return(true);
            }

            bool dummyDataChanged;
            // flexbridge -p <path to fwdata file> -u <username> -v move_lift -g Langprojguid
            var success = FLExBridgeHelper.LaunchFieldworksBridge(
                Path.Combine(projectFolder, Cache.ProjectId.Name + FwFileExtensions.ksFwDataXmlFileExtension),
                Environment.UserName,
                FLExBridgeHelper.MoveLift,
                Cache.LanguageProject.Guid.ToString().ToLowerInvariant(),
                out dummyDataChanged, out _liftPathname);                 // _liftPathname will be null, if no repo was moved.

            if (!success)
            {
                ChooseLangProjectDialog.ReportDuplicateBridge();
                _liftPathname = null;
                return(false);
            }

            return(true);
        }
Пример #7
0
        /// <summary>
        /// Get a new FW project from some Mercurial repository.
        /// The repo may be a lift or full FW repo, but it can be from any source source, as long as the code can create an FW project from it.
        /// </summary>
        /// <returns>Null if the operation was cancelled or otherwise did not work. The full pathname of an fwdata file, if it did work.</returns>
        public static string ObtainProjectFromAnySource(Form parent, IHelpTopicProvider helpTopicProvider, out ObtainedProjectType obtainedProjectType)
        {
            bool   dummy;
            string fwdataFileFullPathname;
            var    liftVersion = "0.13_ldml3";
            var    success     = FLExBridgeHelper.LaunchFieldworksBridge(FwDirectoryFinder.ProjectsDirectory, null, FLExBridgeHelper.Obtain, null,
                                                                         LcmCache.ModelVersion, liftVersion, null, null, out dummy, out fwdataFileFullPathname);

            if (!success)
            {
                ReportDuplicateBridge();
                obtainedProjectType = ObtainedProjectType.None;
                return(null);
            }
            if (string.IsNullOrWhiteSpace(fwdataFileFullPathname))
            {
                obtainedProjectType = ObtainedProjectType.None;
                return(null);                // user canceled.
            }
            obtainedProjectType = ObtainedProjectType.FieldWorks;

            if (fwdataFileFullPathname.EndsWith("lift"))
            {
                fwdataFileFullPathname = CreateProjectFromLift(parent, helpTopicProvider, fwdataFileFullPathname);
                obtainedProjectType    = ObtainedProjectType.Lift;
            }

            UsageReporter.SendEvent("OpenProject", "SendReceive", string.Format("Create from {0} repo", obtainedProjectType.ToString()),
                                    string.Format("vers: {0}, {1}", LcmCache.ModelVersion, liftVersion), 0);
            EnsureLinkedFoldersExist(fwdataFileFullPathname);

            return(fwdataFileFullPathname);
        }
Пример #8
0
        private static bool CheckForFlexBridgeInstalled(UIItemDisplayProperties display)
        {
            var fullName = FLExBridgeHelper.FullFieldWorksBridgePath();

            display.Enabled = FileUtils.FileExists(fullName) && AssemblyName.GetAssemblyName(fullName).Version.Minor >= 5;
            display.Visible = display.Enabled;
            return(display.Visible);
        }
Пример #9
0
        private void UndoExport()
        {
            bool   dataChanged;
            string dummy;

            // Have FLEx Bridge do its 'undo'
            // flexbridge -p <project folder name> #-u username -v undo_export_lift)
            FLExBridgeHelper.LaunchFieldworksBridge(Cache.ProjectId.ProjectFolder, Environment.UserName,
                                                    FLExBridgeHelper.UndoExportLift, null, out dataChanged, out dummy);
        }
Пример #10
0
        public bool OnFLExBridge(object commandObject)
        {
            _mediator.PropertyTable.SetProperty("LastBridgeUsed", "FLExBridge", PropertyTable.SettingsGroup.LocalSettings);
            if (IsDb4oProject)
            {
                var dlg = new Db4oSendReceiveDialog();
                if (dlg.ShowDialog() == DialogResult.Abort)
                {
                    // User clicked on link
                    _mediator.SendMessage("FileProjectSharingLocation", null);
                }
                return(true);
            }

            if (ChangeProjectNameIfNeeded())
            {
                return(true);
            }

            string url;
            var    projectFolder = Cache.ProjectId.ProjectFolder;
            var    savedState    = PrepareToDetectConflicts(projectFolder);
            string dummy;
            var    fullProjectFileName = Path.Combine(projectFolder, Cache.ProjectId.Name + FwFileExtensions.ksFwDataXmlFileExtension);
            bool   dataChanged;
            var    success = FLExBridgeHelper.LaunchFieldworksBridge(fullProjectFileName, Environment.UserName,
                                                                     FLExBridgeHelper.SendReceive, null, out dataChanged, out dummy);

            if (!success)
            {
                ReportDuplicateBridge();
                ProjectLockingService.LockCurrentProject(Cache);
                return(true);
            }

            if (dataChanged)
            {
                var fixer = new FwDataFixer(Cache.ProjectId.Path, new StatusBarProgressHandler(null, null), logger);
                fixer.FixErrorsAndSave();
                bool conflictOccurred = DetectConflicts(projectFolder, savedState);
                var  app          = (LexTextApp)_mediator.PropertyTable.GetValue("App");
                var  newAppWindow = RefreshCacheWindowAndAll(app, fullProjectFileName);

                if (conflictOccurred)
                {
                    //send a message for the reopened instance to display the conflict report, we have been disposed by now
                    newAppWindow.Mediator.SendMessage("ShowConflictReport", null);
                }
            }
            else             //Re-lock project if we aren't trying to close the app
            {
                ProjectLockingService.LockCurrentProject(Cache);
            }
            return(true);
        }
Пример #11
0
        /// <summary>
        /// The method/delegate that gets invoked when Help->About FLEx Bridge is clicked.
        /// </summary>
        /// <param name="argument">Includes the XML command element of the OnAboutFlexBridge message</param>
        /// <returns>true if the message was handled, false if there was an error or the call was deemed inappropriate, or somebody shoudl also try to handle the message.</returns>
        public bool OnAboutFlexBridge(object argument)
        {
            bool   dummy1;
            string dummy2;
            var    success = FLExBridgeHelper.LaunchFieldworksBridge(
                Path.Combine(Cache.ProjectId.ProjectFolder, Cache.ProjectId.Name + FwFileExtensions.ksFwDataXmlFileExtension),
                Environment.UserName,
                FLExBridgeHelper.AboutFLExBridge,
                null,
                out dummy1, out dummy2);

            return(true);
        }
Пример #12
0
 public void ReceiveButtonIsDisabled()
 {
     using (var dlg = new WelcomeToFieldWorksDlg(new FlexHelpTopicProvider(), null, false))
     {
         var receiveButton = ReflectionHelper.GetField(dlg, "receiveButton") as Button;
         if (FLExBridgeHelper.IsFlexBridgeInstalled())
         {
             Assert.That(receiveButton.Enabled, Is.True);
         }
         else
         {
             Assert.That(receiveButton.Enabled, Is.False);
         }
     }
 }
Пример #13
0
        /// <summary>
        /// Do the S/R. This *may* actually create the Lift repository, if it doesn't exist, or it may do a more normal S/R
        /// </summary>
        /// <returns>'true' if the S/R succeed, otherwise 'false'.</returns>
        private bool DoSendReceiveForLift(out bool dataChanged)
        {
            var projectFolder  = Cache.ProjectId.ProjectFolder;
            var liftProjectDir = GetLiftRepositoryFolderFromFwProjectFolder(projectFolder);

            if (!Directory.Exists(liftProjectDir))
            {
                Directory.CreateDirectory(liftProjectDir);
            }
            var    savedState = PrepareToDetectConflicts(liftProjectDir);
            string dummy;
            // flexbridge -p <path to fwdata file> -u <username> -v send_receive_lift
            var success = FLExBridgeHelper.LaunchFieldworksBridge(
                Path.Combine(projectFolder, Cache.ProjectId.Name + FwFileExtensions.ksFwDataXmlFileExtension),
                Environment.UserName,
                FLExBridgeHelper.SendReceiveLift,                 // May create a new lift repo in the process of doing the S/R. Or, it may just use the extant lift repo.
                null,
                out dataChanged, out dummy);

            if (!success)
            {
                ChooseLangProjectDialog.ReportDuplicateBridge();
                dataChanged   = false;
                _liftPathname = null;
                return(false);
            }

            _liftPathname = GetLiftPathname(liftProjectDir);

            if (_liftPathname == null)
            {
                dataChanged = false;                 // If there is no lift file, there cannot be any new data.
                return(false);
            }

            return(true);
        }