Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevSpaces Gateway plugin minimal impl #10

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea
.qodana
build
.DS_Store
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = com.github.azatsarynnyy.gatewayplugin
pluginGroup = com.github.devspaces.gateway
pluginName = gateway-plugin
pluginRepositoryUrl = https://github.com/che-incubator/gateway-plugin
pluginRepositoryUrl = https://github.com/redhat-developer/devspaces-gateway-plugin
# SemVer format -> https://semver.org
pluginVersion = 0.0.1

Expand All @@ -11,8 +11,8 @@ pluginSinceBuild = 223
pluginUntilBuild = 233.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
platformVersion = 2022.3.3
platformType = GW
platformVersion = 233.14015.42-CUSTOM-SNAPSHOT

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

31 changes: 31 additions & 0 deletions src/main/kotlin/com/github/devspaces/gateway/DevSpacesBundle.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.github.devspaces.gateway

import com.intellij.DynamicBundle
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey

@NonNls
private const val BUNDLE = "messages.DevSpacesBundle"

object DevSpacesBundle : DynamicBundle(BUNDLE) {

@JvmStatic
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
getMessage(key, *params)

@Suppress("unused")
@JvmStatic
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
getLazyMessage(key, *params)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.github.devspaces.gateway

import com.jetbrains.gateway.api.GatewayConnector
import com.jetbrains.gateway.api.GatewayConnectorDocumentationPage
import com.jetbrains.gateway.api.GatewayConnectorView
import com.jetbrains.rd.util.lifetime.Lifetime
import javax.swing.Icon

class DevSpacesConnector : GatewayConnector {
override fun getConnectorId() = "devspaces.connector"

override val icon: Icon
get() = DevSpacesIcons.LOGO

override fun createView(lifetime: Lifetime): GatewayConnectorView {
return DevSpacesView()
}

override fun getActionText(): String {
return DevSpacesBundle.message("connector.action.text")
}

override fun getDescription(): String {
return DevSpacesBundle.message("connector.description")

Check warning on line 35 in src/main/kotlin/com/github/devspaces/gateway/DevSpacesConnector.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Connects to a Dev Spaces Workspace' is not properly capitalized. It should have sentence capitalization
}

override fun getDocumentationAction() = GatewayConnectorDocumentationPage("https://access.redhat.com/documentation/en-us/red_hat_openshift_dev_spaces")

// override fun getRecentConnections(setContentCallback: (Component) -> Unit): GatewayRecentConnections {
// }

override fun getTitle(): String {
return DevSpacesBundle.message("connector.title")
}

override fun isAvailable(): Boolean {
return true
}
}
18 changes: 18 additions & 0 deletions src/main/kotlin/com/github/devspaces/gateway/DevSpacesIcons.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.github.devspaces.gateway

import com.intellij.openapi.util.IconLoader

object DevSpacesIcons {
val LOGO = IconLoader.getIcon("dev-spaces-logo.svg", javaClass)
}
38 changes: 38 additions & 0 deletions src/main/kotlin/com/github/devspaces/gateway/DevSpacesView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.github.devspaces.gateway

import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
import com.intellij.ui.dsl.builder.BottomGap
import com.intellij.ui.dsl.builder.panel
import com.jetbrains.gateway.api.GatewayConnectorView
import com.jetbrains.gateway.api.GatewayUI

class DevSpacesView : GatewayConnectorView {

override val component = panel {
row {
panel {
separator(WelcomeScreenUIManager.getSeparatorColor())
indent {
row {
button("Back") {
GatewayUI.getInstance().reset()
}
}
}
}
}.bottomGap(BottomGap.SMALL)
}.apply {
this.background = WelcomeScreenUIManager.getMainAssociatedComponentBackground()
}
}
17 changes: 7 additions & 10 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
<id>com.github.azatsarynnyy.gatewayplugin</id>
<name>gateway-plugin Template</name>
<vendor>azatsarynnyy</vendor>
<id>com.github.devspaces.gateway</id>
<name>OpenShift DevSpaces</name>
<vendor>Red Hat</vendor>

<depends>com.intellij.modules.platform</depends>

<resource-bundle>messages.MyBundle</resource-bundle>
<resource-bundle>messages.DevSpacesBundle</resource-bundle>

<extensions defaultExtensionNs="com.intellij">
<toolWindow factoryClass="com.github.azatsarynnyy.gatewayplugin.toolWindow.MyToolWindowFactory" id="MyToolWindow"/>
<extensions defaultExtensionNs="com.jetbrains">
<gatewayConnector implementation="com.github.devspaces.gateway.DevSpacesConnector"/>
<!-- <gatewayConnectionProvider implementation="com.github.devspaces.gateway.DevSpacesConnectionProvider"/>-->
</extensions>

<applicationListeners>
<listener class="com.github.azatsarynnyy.gatewayplugin.listeners.MyApplicationActivationListener" topic="com.intellij.openapi.application.ApplicationActivationListener"/>
</applicationListeners>
</idea-plugin>
1 change: 1 addition & 0 deletions src/main/resources/dev-spaces-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/messages/DevSpacesBundle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
connector.action.text=Connect to Dev Spaces
connector.description=Connects to a Dev Spaces Workspace
connector.title=Dev Spaces
3 changes: 0 additions & 3 deletions src/main/resources/messages/MyBundle.properties

This file was deleted.

This file was deleted.

42 changes: 42 additions & 0 deletions src/test/kotlin/com/github/devspaces/gateway/MyPluginTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2024 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.github.devspaces.gateway

//import com.intellij.ide.highlighter.XmlFileType
//import com.intellij.psi.xml.XmlFile
import com.intellij.testFramework.TestDataPath
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.util.PsiErrorElementUtil

@TestDataPath("\$CONTENT_ROOT/src/test/testData")
class MyPluginTest : BasePlatformTestCase() {

// fun testXMLFile() {
// val psiFile = myFixture.configureByText(XmlFileType.INSTANCE, "<foo>bar</foo>")
// val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java)
//
// assertFalse(PsiErrorElementUtil.hasErrors(project, xmlFile.virtualFile))
//
// assertNotNull(xmlFile.rootTag)
//
// xmlFile.rootTag?.let {
// assertEquals("foo", it.name)
// assertEquals("bar", it.value.text)
// }
// }

fun testRename() {
// myFixture.testRename("foo.xml", "foo_after.xml", "a2")
}

override fun getTestDataPath() = "src/test/testData/rename"
}
Loading