public FiberDeviceConnectionCommand()
        {
            try
            {
                if (ArcMap.Editor == null)
                {
                    _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Editor License not found.", "FiberDeviceConnectionCommand()");
                    return;
                }

                // -----------------------------------
                // Construct a new hook helper and a
                // connections helper that does all the
                // cable to device connection work
                // -----------------------------------
                _hookHelper = HookHelperExt.Instance(this.Hook);
                _deviceConnectionHelper = new FiberDeviceConnectionHelper(_hookHelper, ArcMap.Editor as IEditor3);

                // -----------------------------------
                // Always hide connections window on
                // any initialization
                // -----------------------------------
                UID dockWinID = new UIDClass();
                dockWinID.Value = @"esriTelcoTools_FiberDeviceConnectionWindow";
                IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
                dockWindow.Show(false);

                // -----------------------------------
                // Track the start and stop of editing
                // -----------------------------------
                Events.OnStartEditing += new IEditEvents_OnStartEditingEventHandler(Events_OnStartEditing);
                Events.OnStopEditing += new IEditEvents_OnStopEditingEventHandler(Events_OnStopEditing);
            }
            catch (Exception ex)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "FiberDeviceConnectionCommand()", ex.Message);
            }
        }
        public FiberEditorExtension()
        {
            try
            {
                // --------------------------------------
                // Initialize log window with log helper
                // --------------------------------------
                _logHelper = LogHelper.Instance();
                TelecomToolsLogWindow.AddinImpl winImpl =
                    AddIn.FromID<TelecomToolsLogWindow.AddinImpl>(
                    ThisAddIn.IDs.Esri_Telecom_Tools_Windows_TelecomToolsLogWindow);
                TelecomToolsLogWindow logWindow = winImpl.UI;
                logWindow.InitLog(_logHelper);

                // --------------------
                // Build a hook helper
                // --------------------
                _hookHelper = HookHelperExt.Instance(this.Hook);

                // -------------------------------------------
                // Initialize telecom workspace helper.
                //
                // Listen to ActiveViewChanged event.
                //
                // If this happens the focus map more than
                // likely changed. Since the tools go after
                // layers in the TOC we probably need to close
                // the current telecom workspace since
                // editing etc could not longer be done.
                // Should add code to ask for saving changes.
                // -------------------------------------------
                _wkspHelper = TelecomWorkspaceHelper.Instance();
                _wkspHelper.ActiveViewChanged += new EventHandler(_wkspHelper_ActiveViewChanged);

                // -------------------------------------------
                // Build helpers that actually do all object
                // creation work for special feature types
                // -------------------------------------------
                _fiberCableHelper = new FiberCableConfigHelper(_hookHelper, ArcMap.Editor as IEditor3);
                _fiberDeviceHelper = new FiberDeviceConfigHelper(_hookHelper, ArcMap.Editor as IEditor3);

                // --------------------------------------------
                // Splice and Connection helpers
                // --------------------------------------------
                _spliceHelper = new FiberSpliceHelper(_hookHelper, ArcMap.Editor as IEditor3);
                _connectionHelper = new FiberDeviceConnectionHelper(_hookHelper, ArcMap.Editor as IEditor3);

                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Telecom Extension Constructed.");
            }
            catch (Exception ex)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "General error.", ex.ToString());
            }
        }
        /// <summary>
        /// Update the dropdowns of features on the UI
        /// </summary>
        /// <param name="helper">Helper class</param>
        private void PopulateDropDowns(FiberDeviceConnectionHelper helper)
        {
            // Clear the existing choices
            cboFrom.Items.Clear();
            cboTo.Items.Clear();
            lblAvailableFrom.Text = "";
            lblAvailableTo.Text = "";

            // Get the features and the display index for use when creating the wrapper
            ESRI.ArcGIS.Carto.IFeatureLayer ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.FiberCableFtClassName);
            int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField);

            // Get the selected features
            List<ESRI.ArcGIS.Geodatabase.IFeature> selectedFts = _hookHelper.GetSelectedFeatures(ftLayer);

            // Add each of the fiber features to the drop down
            for (int ftIdx = 0; ftIdx < selectedFts.Count; ftIdx++)
            {
                FiberCableWrapper w = new FiberCableWrapper(selectedFts[ftIdx], displayIdx);
                cboFrom.Items.Add(w);
            }

            // Now do that same thing for each of the device feature classes
            string[] deviceClassNames = ConfigUtil.DeviceFeatureClassNames;
            for (int deviceClassIdx = 0; deviceClassIdx < deviceClassNames.Length; deviceClassIdx++)
            {
                string ftClassName = deviceClassNames[deviceClassIdx];

                // Get the features and the display index for use when creating the wrapper
                ftLayer = _hookHelper.FindFeatureLayer(ftClassName);
                if (ftLayer != null) // what if layer removed from map
                {
                    selectedFts = _hookHelper.GetSelectedFeatures(ftLayer);

                    displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField);

                    for (int ftIdx = 0; ftIdx < selectedFts.Count; ftIdx++)
                    {
                        DeviceWrapper w = new DeviceWrapper(selectedFts[ftIdx], displayIdx);
                        cboFrom.Items.Add(w);
                    }
                }
            }

            // Preselect the first choice
            if (0 < cboFrom.Items.Count)
            {
                cboFrom.SelectedItem = cboFrom.Items[0];
            }
        }
        /// <summary>
        /// To prepare and display the form to the user
        /// </summary>
        /// <param name="connectionHelper">Class providing helper methods for connections</param>
        public void DisplayConnections(FiberDeviceConnectionHelper connectionHelper, HookHelperExt hookHelper)
        {
            _connectionHelper = connectionHelper;
            _hookHelper = hookHelper;

            // Changes the GUI appropriately
            SetEditState(_isEditing);

            // Populate drop downs with splice closure and device info.
            PopulateDropDowns(connectionHelper);
        }