Esempio n. 1
0
        public static JavaEditorBase Disconnect(IWpfTextView textView, Collection <ITextBuffer> subjectBuffers)
        {
            ServerProxy            javaPkgServer          = null;
            JavaEditor             javaEditor             = null;
            JavaUnconfiguredEditor javaUnconfiguredEditor = null;

            textView.Properties.TryGetProperty <ServerProxy>(typeof(ServerProxy), out javaPkgServer);
            textView.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor);
            textView.Properties.TryGetProperty <JavaUnconfiguredEditor>(typeof(JavaUnconfiguredEditor), out javaUnconfiguredEditor);

            textView.Properties.RemoveProperty(typeof(JavaUnconfiguredEditor));
            textView.Properties.RemoveProperty(typeof(ServerProxy));
            textView.Properties.RemoveProperty(typeof(JavaEditor));

            foreach (var buffer in subjectBuffers)
            {
                buffer.Properties.RemoveProperty(typeof(JavaUnconfiguredEditor));
                buffer.Properties.RemoveProperty(typeof(ServerProxy));
                buffer.Properties.RemoveProperty(typeof(JavaEditor));
            }

            if (javaPkgServer != null && javaEditor != null && javaEditor.TypeRootIdentifier != null)
            {
                javaPkgServer.Send(javaEditor, ProtocolHandlers.CreateDisposeTypeRootRequest(javaEditor.TypeRootIdentifier)).ContinueWith((System.Threading.Tasks.Task <Protocol.Response> responseTask) =>
                {
                    JavaPkgServerMgr.ReleaseProxy(javaPkgServer);
                });
            }

            return(javaEditor != null ? (JavaEditorBase)javaEditor : (JavaEditorBase)javaUnconfiguredEditor);
        }
        void textView_GotAggregateFocus(object sender, EventArgs e)
        {
            var                    textView               = sender as IWpfTextView;
            JavaEditor             javaEditor             = null;
            JavaUnconfiguredEditor javaUnconfiguredEditor = null;

            if (textView.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor))
            {
                // Force an update in case something changed in the configuration since the last time we opened the file in the editor
                javaEditor.Update(textView.TextSnapshot, true);
            }
            else if (textView.Properties.TryGetProperty <JavaUnconfiguredEditor>(typeof(JavaUnconfiguredEditor), out javaUnconfiguredEditor))
            {
                javaUnconfiguredEditor.Update();
            }
        }
Esempio n. 3
0
        public JavaMargin(IWpfTextView textView)
        {
            TextView = textView;
            Root     = new JavaMarginUI();

            JavaEditor             javaEditor             = null;
            JavaUnconfiguredEditor javaUnconfiguredEditor = null;

            if (textView.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor))
            {
                javaEditor.OperationStarted   += javaEditor_OperationStarted;
                javaEditor.OperationCompleted += javaEditor_OperationCompleted;
                javaEditor.EditorReplaced     += javaEditor_EditorReplaced;
            }
            else if (textView.Properties.TryGetProperty <JavaUnconfiguredEditor>(typeof(JavaUnconfiguredEditor), out javaUnconfiguredEditor))
            {
                Root.MessageBanner = "Java file is not part of an workspace. Intellisense is not available";
                javaUnconfiguredEditor.EditorReplaced += javaEditor_EditorReplaced;
            }

            // Check JDK installation
            var jdkStatus = Helpers.JDKHelpers.GetJavaPathDirectory();

            switch (jdkStatus.Item2)
            {
            case Helpers.JDKHelpers.Status.JDKRegKeyNotFound:
                Root.MessageBanner = "Java Developer Kit installation not found (Status.JDKRegKeyNotFound). Intellisense is not available";
                break;

            case Helpers.JDKHelpers.Status.CurrentVersionRegKeyNotFound:
                Root.MessageBanner = "Java Developer Kit installation not found (Status.CurrentVersionRegKeyNotFound). Intellisense is not available";
                break;

            case Helpers.JDKHelpers.Status.JavaHomeFolderNotFound:
                Root.MessageBanner = "Java Developer Kit installation not found (Status.JavaHomeFolderNotFound). Intellisense is not available";
                break;

            case Helpers.JDKHelpers.Status.JavaBinFolderNotFound:
                Root.MessageBanner = "Java Developer Kit installation not found (Status.JavaBinFolderNotFound). Intellisense is not available";
                break;

            case Helpers.JDKHelpers.Status.JavaExeFileNotFound:
                Root.MessageBanner = "Java Developer Kit installation not found (Status.JavaExeFileNotFound). Intellisense is not available";
                break;
            }
        }
Esempio n. 4
0
        public void Dispose()
        {
            if (!isDisposed)
            {
                Root = null;

                JavaEditor             javaEditor             = null;
                JavaUnconfiguredEditor javaUnconfiguredEditor = null;
                if (TextView.Properties.TryGetProperty <JavaEditor>(typeof(JavaEditor), out javaEditor))
                {
                    javaEditor.OperationStarted   -= javaEditor_OperationStarted;
                    javaEditor.OperationCompleted -= javaEditor_OperationCompleted;
                    javaEditor.EditorReplaced     -= javaEditor_EditorReplaced;
                }
                else if (TextView.Properties.TryGetProperty <JavaUnconfiguredEditor>(typeof(JavaUnconfiguredEditor), out javaUnconfiguredEditor))
                {
                    javaUnconfiguredEditor.EditorReplaced -= javaEditor_EditorReplaced;
                }

                GC.SuppressFinalize(this);
                isDisposed = true;
            }
        }
Esempio n. 5
0
        public static JavaUnconfiguredEditor Unconfigure(IWpfTextView textView, Collection <ITextBuffer> subjectBuffers)
        {
            var oldEditor = Disconnect(textView, subjectBuffers);

            string                 fileName               = VSHelpers.GetFileName(textView);
            EclipseWorkspace       eclipseWorkspace       = EclipseWorkspace.FromFilePath(fileName);
            JavaUnconfiguredEditor javaUnconfiguredEditor = null;

            javaUnconfiguredEditor = textView.Properties.GetOrCreateSingletonProperty <JavaUnconfiguredEditor>(() => new JavaUnconfiguredEditor(subjectBuffers, textView, JavaPkgServerMgr, eclipseWorkspace));
            Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured");

            if (oldEditor != null)
            {
                oldEditor.Fire_EditorReplaced(javaUnconfiguredEditor);
            }

            foreach (var buffer in subjectBuffers)
            {
                buffer.Properties.AddProperty(typeof(JavaUnconfiguredEditor), javaUnconfiguredEditor);
            }

            return(javaUnconfiguredEditor);
        }