generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/github/iml885203/intellijgitopen/MyNotifier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.iml885203.intellijgitopen | ||
|
||
import com.intellij.notification.NotificationGroupManager | ||
import com.intellij.notification.NotificationType | ||
import com.intellij.openapi.project.Project | ||
|
||
object MyNotifier { | ||
fun notifyError(project: Project, content: String) { | ||
NotificationGroupManager.getInstance() | ||
.getNotificationGroup("Git Open") | ||
.createNotification(content, NotificationType.ERROR) | ||
.notify(project) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/com/github/iml885203/intellijgitopen/actions/GitOpenRemoteRepoAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.iml885203.intellijgitopen.actions | ||
|
||
import com.github.iml885203.intellijgitopen.MyNotifier | ||
import com.intellij.ide.BrowserUtil | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.diagnostic.thisLogger | ||
import org.eclipse.jgit.api.Git | ||
import org.eclipse.jgit.errors.RepositoryNotFoundException | ||
import org.eclipse.jgit.transport.RemoteConfig | ||
import org.eclipse.jgit.transport.URIish | ||
import java.io.File | ||
|
||
class GitOpenRemoteRepoAction : AnAction() { | ||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
try { | ||
val remoteUrl = getRemoteUrl(project.basePath ?: return) | ||
thisLogger().info("Remote URL: $remoteUrl") | ||
BrowserUtil.browse(remoteUrl) | ||
} catch (ex: RepositoryNotFoundException) { | ||
MyNotifier.notifyError(project, "The Git repository could not be found at the specified location.") | ||
} | ||
} | ||
|
||
private fun getRemoteUrl(projectPath: String): String { | ||
val git = Git.open(File(projectPath)) | ||
val config = git.repository.config | ||
val remoteConfig = RemoteConfig(config, "origin") | ||
val uris: List<URIish> = remoteConfig.urIs | ||
return uris[0].toString() | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
src/main/kotlin/com/github/iml885203/intellijgitopen/toolWindow/MyToolWindowFactory.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html --> | ||
<idea-plugin> | ||
<id>com.github.iml885203.intellijgitopen</id> | ||
<name>IntelliJ-git-open</name> | ||
<vendor>iml885203</vendor> | ||
<name>Git Open</name> | ||
<vendor>Logan</vendor> | ||
|
||
<depends>com.intellij.modules.platform</depends> | ||
|
||
<resource-bundle>messages.MyBundle</resource-bundle> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<toolWindow factoryClass="com.github.iml885203.intellijgitopen.toolWindow.MyToolWindowFactory" id="MyToolWindow"/> | ||
<notificationGroup id="Git Open" | ||
displayType="BALLOON" | ||
key="notification.group.name"/> | ||
</extensions> | ||
|
||
<applicationListeners> | ||
<listener class="com.github.iml885203.intellijgitopen.listeners.MyApplicationActivationListener" topic="com.intellij.openapi.application.ApplicationActivationListener"/> | ||
</applicationListeners> | ||
|
||
<actions> | ||
<action class="com.github.iml885203.intellijgitopen.actions.GitOpenRemoteRepoAction" id="com.github.iml885203.intellijgitopen.actions.GitOpenRemoteRepoAction" text="Git Open Remote Repo"> | ||
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt G"/> | ||
</action> | ||
</actions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
notification.group.name=Git open | ||
projectService=Project service: {0} | ||
randomLabel=The random number is: {0} | ||
shuffle=Shuffle |