예제 #1
0
        /// <summary>
        /// Advices the perspective to make the given <paramref name="dataView"/> visible at the <paramref name="viewPosition"/>.
        /// </summary>
        /// <param name="dataView">Data view to show</param>
        /// <param name="viewPosition">Target view position</param>
        public virtual void ShowView(IDataView dataView, EViewPosition viewPosition)
        {
            if (dataView == null)
            {
                return;
            }

            try {
                // Notify data view to init
                dataView.Init();

                // Set up new view
                IWidgetFactory widgetFactory = FactoryProvider.Instance.GetWidgetFactory();
                dataView.WidgetFactory = widgetFactory;

                // Make view visible
                OnShowDataView(dataView, viewPosition);

                // Update internal state and dispatch events
                ActiveDataViews.Add(dataView);
                PerspectiveEventManager.Dispatch(lstnr => lstnr.OnWorkbenchPartOpened(dataView), OnDispatchWorkbenchEventException);
            } catch (Exception ex) {
                _log.Error($"Error on showing data view '{dataView}' by perspective '{this}'.", ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Advices the perspective to make the given editor visible.
        /// </summary>
        /// <param name="editor">Editor instance</param>
        /// <param name="editorInput">Input for the editor</param>
        public virtual void ShowEditor(IEditor editor, IEditorInput editorInput)
        {
            if (editor == null)
            {
                return;
            }

            try {
                // Close active editor if there is any
                IEditor activeEditor = ActiveEditor;
                if (activeEditor != null)
                {
                    if (!CanCloseEditor(activeEditor))
                    {
                        return;
                    }
                }

                // Set up new editor
                editor.WidgetFactory = FactoryProvider.Instance.GetWidgetFactory();
                editor.SetEditorInput(editorInput);

                // Make editor visible
                OnShowEditor(editor);

                // Update internal state and dispatch events
                ActiveEditor = editor;
                PerspectiveEventManager.Dispatch(lstnr => lstnr.OnWorkbenchPartOpened(editor), OnDispatchWorkbenchEventException);
            } catch (Exception ex) {
                _log.Error($"Error on showing editor '{editor}' by perspective '{this}'.", ex);
            }
        }
예제 #3
0
        /// <summary>
        /// Closes the editor referenced by the given instance. If none is open, nothing will happen. Note, there is no guarantee the editor is closed.
        /// The user may cancel the process when the editor is dirty and the user refuses the save dialog.
        /// </summary>
        /// <param name="editor">Editor instance to close</param>
        /// <param name="silently">If TRUE the editor is closed silently</param>
        /// <returns></returns>
        protected virtual bool CloseEditor(IEditor editor, bool silently)
        {
            if (editor == null)
            {
                return(false);
            }
            if (!Equals(ActiveEditor, editor))
            {
                return(false);
            }
            if (!silently && !CanCloseEditor(editor))
            {
                return(false);
            }

            try {
                OnCloseEditor(editor);
                ActiveEditor = null;
                PerspectiveEventManager.Dispatch(lstnr => lstnr.OnWorkbenchPartClosed(editor), OnDispatchWorkbenchEventException);
                return(true);
            } catch (Exception ex) {
                _log.Error($"Error on closing editor '{editor}' by perspective '{this}'.", ex);
                return(false);
            }
        }
예제 #4
0
        /// <summary> Is invoked when the dock content got the focus. </summary>
        /// <param name="sender">Event sender</param>
        /// <param name="eventArgs">Event arguments</param>
        private void OnDockContentGotFocus(object sender, EventArgs eventArgs)
        {
            DockContent dockContent = sender as DockContent;

            if (dockContent == null)
            {
                return;
            }
            IWorkbenchPart workbenchPart = dockContent.Tag as IWorkbenchPart;

            if (workbenchPart == null)
            {
                return;
            }
            PerspectiveEventManager.Dispatch(lstnr => lstnr.OnWorkbenchPartActivated(workbenchPart), OnDispatchWorkbenchEventException);
        }