diff --git a/build.gradle.kts b/build.gradle.kts index dee52d52..4ee72d6d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,7 @@ subprojects { mavenCentral() maven("https://jitpack.io") maven("https://www.jetbrains.com/intellij-repository/releases") + maven("https://www.jetbrains.com/intellij-repository/snapshots") maven("https://cache-redirector.jetbrains.com/intellij-dependencies") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c39957f8..c35d9d5e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -21,6 +21,9 @@ * Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic * if you need additional information or have any questions. */ + +import java.util.* + plugins { `kotlin-dsl` } @@ -28,10 +31,18 @@ plugins { repositories { mavenCentral() maven("https://www.jetbrains.com/intellij-repository/releases") + maven("https://www.jetbrains.com/intellij-repository/snapshots") maven("https://cache-redirector.jetbrains.com/intellij-dependencies") } -val intellijPlatformVersion: String by project +val gradleProperties = Properties() +val gradlePropertiesFile = project.file("../gradle.properties") +if (gradlePropertiesFile.canRead()) { + gradleProperties.load(gradlePropertiesFile.inputStream()) +} + +val intellijPlatformVersion: String by gradleProperties + val serializationVersion: String by project dependencies { diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index e805be77..8ddf6a5d 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -22,5 +22,4 @@ # if you need additional information or have any questions. # -intellijPlatformVersion=213.6461.23 serializationVersion=1.3.1 diff --git a/buildSrc/src/main/kotlin/runIdeaTaskBase.kt b/buildSrc/src/main/kotlin/runIdeaTaskBase.kt index 263d3962..edee5d70 100644 --- a/buildSrc/src/main/kotlin/runIdeaTaskBase.kt +++ b/buildSrc/src/main/kotlin/runIdeaTaskBase.kt @@ -45,8 +45,8 @@ public fun Project.createRunIdeaTask( println("JDK home dir: $jdkHome") - val ideaPathsSelector = "ProjectorIntelliJIdea" val prefix = getIdePrefix(ideaPath) + val ideaPathsSelector = "Projector${prefix ?: "Idea"}" val (classToLaunchProperty, launcherClassName) = getLaunchingSetup(isAgent) diff --git a/gradle.properties b/gradle.properties index 2a863c6f..f2a7398d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,12 +21,13 @@ # Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic # if you need additional information or have any questions. # -intellijPlatformVersion=213.6461.23 +intellijJcefVersion=89.0.12-g2b76680-chromium-89.0.4389.90-api-1.6 +intellijPlatformVersion=213.6777.52 intellijPluginVersion=1.3.0 javassistVersion=3.28.0-GA kotlinVersion=1.6.10 mockitoKotlinVersion=4.0.0 -projectorClientVersion=3d0453c9 +projectorClientVersion=67b2cd9f projectorClientGroup=com.github.JetBrains.projector-client targetJvm=11 jetbrainsMonoVersion=2.242 diff --git a/projector-server/build.gradle.kts b/projector-server/build.gradle.kts index 8d6574c7..fc898a7e 100644 --- a/projector-server/build.gradle.kts +++ b/projector-server/build.gradle.kts @@ -22,6 +22,7 @@ * if you need additional information or have any questions. */ +import com.intellij.openapi.util.BuildNumber import java.net.URL import java.util.* import java.util.zip.ZipFile @@ -49,18 +50,29 @@ val projectorClientGroup: String by project val projectorClientVersion: String by project val mockitoKotlinVersion: String by project val kotlinVersion: String by project +val intellijJcefVersion: String by project val intellijPlatformVersion: String by project +val intelliJVersionRemovedSuffix = intellijPlatformVersion.takeWhile { it.isDigit() || it == '.' } // in case of EAP +val intellijPlatformBuildNumber = BuildNumber.fromString(intelliJVersionRemovedSuffix)!! + dependencies { implementation("$projectorClientGroup:projector-common:$projectorClientVersion") + implementation("$projectorClientGroup:projector-ij-common:$projectorClientVersion") implementation("$projectorClientGroup:projector-server-core:$projectorClientVersion") implementation("$projectorClientGroup:projector-util-loading:$projectorClientVersion") implementation("$projectorClientGroup:projector-util-logging:$projectorClientVersion") api(project(":projector-awt")) - compileOnly("com.jetbrains.intellij.platform:code-style:$intellijPlatformVersion") + if (intellijPlatformBuildNumber >= BuildNumber.fromString("203.5981.165")!!) { + compileOnly("com.jetbrains.intellij.platform:code-style:$intellijPlatformVersion") + } else { + compileOnly("com.jetbrains.intellij.platform:lang:$intellijPlatformVersion") + } + compileOnly("com.jetbrains.intellij.platform:core-ui:$intellijPlatformVersion") compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijPlatformVersion") + compileOnly("org.jetbrains.intellij.deps.jcef:jcef:$intellijJcefVersion") testImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion") testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion") diff --git a/projector-server/src/main/kotlin/org/jetbrains/projector/server/CommonQueueEventSender.kt b/projector-server/src/main/kotlin/org/jetbrains/projector/server/CommonQueueEventSender.kt new file mode 100644 index 00000000..f727d451 --- /dev/null +++ b/projector-server/src/main/kotlin/org/jetbrains/projector/server/CommonQueueEventSender.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019-2022, JetBrains s.r.o. and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. JetBrains designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic + * if you need additional information or have any questions. + */ +@file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE") + +package org.jetbrains.projector.server + +import org.jetbrains.projector.awt.peer.PComponentPeer +import org.jetbrains.projector.common.EventSender +import org.jetbrains.projector.common.event.BrowserShowEventPart +import org.jetbrains.projector.common.event.ServerEventPart +import org.jetbrains.projector.common.protocol.toClient.ServerBrowserEvent +import org.jetbrains.projector.common.protocol.toClient.ServerEvent +import org.jetbrains.projector.util.loading.UseProjectorLoader +import sun.awt.AWTAccessor +import java.awt.Component +import java.awt.peer.ComponentPeer +import javax.swing.SwingUtilities + +@UseProjectorLoader +class CommonQueueEventSender : EventSender { + + override fun sendEvent(event: ServerEvent) { + ProjectorServer.appendToCommonQueue(event) + } + + override fun sendEventPart(part: ServerEventPart) { + val serverEvent = when (part) { + is BrowserShowEventPart -> ServerBrowserEvent.ShowEvent(part.browserId, part.show, part.component?.pWindowId) + } + + sendEvent(serverEvent) + } + + private val Component.pWindowId: Int? + get() = let { + val root = SwingUtilities.getRoot(it) ?: return@let null + val peer = AWTAccessor.getComponentAccessor().getPeer(root) as? PComponentPeer ?: return@let null + peer.pWindow.id + } +} diff --git a/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt b/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt index 666759d3..c4f4e263 100644 --- a/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt +++ b/projector-server/src/main/kotlin/org/jetbrains/projector/server/ProjectorServer.kt @@ -43,6 +43,7 @@ import org.jetbrains.projector.common.protocol.data.UserKeymap import org.jetbrains.projector.common.protocol.handshake.* import org.jetbrains.projector.common.protocol.toClient.* import org.jetbrains.projector.common.protocol.toServer.* +import org.jetbrains.projector.ij.jcef.* import org.jetbrains.projector.server.core.* import org.jetbrains.projector.server.core.convert.toAwt.* import org.jetbrains.projector.server.core.convert.toClient.* @@ -193,6 +194,7 @@ class ProjectorServer private constructor( previousWindowEvents = emptySet() caretInfoUpdater.createCaretInfoEvent() PanelUpdater.updateAll() + updateCefBrowsersSafely() } is ReadyClientSettings -> { @@ -501,6 +503,7 @@ class ProjectorServer private constructor( is ClientWindowsDeactivationEvent -> { updateWindowsState(message.windowIds, WindowEvent.WINDOW_DEACTIVATED) } + is ClientNotificationEvent -> { if (!IdeState.isIdeAttached) return @@ -514,6 +517,20 @@ class ProjectorServer private constructor( val notification = Notification("ProjectorClient", message.title, message.message, intellijNotificationType) Notifications.Bus.notify(notification) } + + is ClientJcefEvent -> { + val projectorCefBrowser = ProjectorCefBrowser.getInstance(message.browserId) ?: return + + val messageRouters = projectorCefBrowser.client.getMessageRouters() + val eventRouter = messageRouters.find { + it.messageRouterConfig?.jsQueryFunction == message.functionName + } ?: return + + val handlers = eventRouter.getHandlers() + handlers.forEach { + it.onProjectorQuery(projectorCefBrowser, message.data) + } + } } } @@ -918,6 +935,10 @@ class ProjectorServer private constructor( } } + fun appendToCommonQueue(event: ServerEvent) { + lastStartedServer?.apply { commonQueue += event } + } + @Suppress("MemberVisibilityCanBePrivate") // used in CWM var lastStartedServer: ProjectorServer? = null private set diff --git a/projector-server/src/main/kotlin/org/jetbrains/projector/server/platform/Compatibility.kt b/projector-server/src/main/kotlin/org/jetbrains/projector/server/platform/Compatibility.kt index f8955953..8f0e069c 100644 --- a/projector-server/src/main/kotlin/org/jetbrains/projector/server/platform/Compatibility.kt +++ b/projector-server/src/main/kotlin/org/jetbrains/projector/server/platform/Compatibility.kt @@ -25,20 +25,12 @@ package org.jetbrains.projector.server.platform -import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.editor.colors.EditorColorsScheme import com.intellij.openapi.editor.markup.RangeHighlighter import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.openapi.util.BuildNumber +import org.jetbrains.projector.common.intellij.buildAtLeast import org.jetbrains.projector.util.loading.UseProjectorLoader -fun buildAtLeast(version: String): Boolean { - val versionToCheck = BuildNumber.fromString(version) ?: throw IllegalArgumentException("Invalid version string $version") - val currentVersion = ApplicationInfo.getInstance().build - - return currentVersion >= versionToCheck -} - private val isColorSchemeRequired: Boolean by lazy { buildAtLeast("202.6397.94") } @Suppress("DEPRECATION") diff --git a/projector-server/src/main/resources/META-INF/services/org.jetbrains.projector.common.EventSender b/projector-server/src/main/resources/META-INF/services/org.jetbrains.projector.common.EventSender new file mode 100644 index 00000000..ae4945d1 --- /dev/null +++ b/projector-server/src/main/resources/META-INF/services/org.jetbrains.projector.common.EventSender @@ -0,0 +1,24 @@ +# +# Copyright (c) 2019-2022, JetBrains s.r.o. and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. JetBrains designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact JetBrains, Na Hrebenech II 1718/10, Prague, 14000, Czech Republic +# if you need additional information or have any questions. +# +org.jetbrains.projector.server.CommonQueueEventSender diff --git a/settings.gradle.kts b/settings.gradle.kts index a9a278f6..0370c86a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -49,10 +49,11 @@ val localProperties = Properties().apply { if (localProperties["useLocalProjectorClient"] == "true") { includeBuild("../projector-client") { dependencySubstitution { - substitute(module("$projectorClientGroup:projector-common")).with(project(":projector-common")) - substitute(module("$projectorClientGroup:projector-server-core")).with(project(":projector-server-core")) - substitute(module("$projectorClientGroup:projector-util-loading")).with(project(":projector-util-loading")) - substitute(module("$projectorClientGroup:projector-util-logging")).with(project(":projector-util-logging")) + substitute(module("$projectorClientGroup:projector-common")).using(project(":projector-common")) + substitute(module("$projectorClientGroup:projector-ij-common")).using(project(":projector-ij-common")) + substitute(module("$projectorClientGroup:projector-server-core")).using(project(":projector-server-core")) + substitute(module("$projectorClientGroup:projector-util-loading")).using(project(":projector-util-loading")) + substitute(module("$projectorClientGroup:projector-util-logging")).using(project(":projector-util-logging")) } } }