Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
meiMingle committed Jul 19, 2023
1 parent 3b86354 commit 9d2ed92
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 63 deletions.
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ org.gradle.caching = true

# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
systemProp.org.gradle.unsafe.kotlin.assignment = true

org.gradle.parallel = true
org.gradle.jvmargs = '-Dfile.encoding=UTF-8'

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.github.meimingle.tsvnpwdintellij.actions

import com.github.meimingle.tsvnpwdintellij.bundle.TSvnPwdBundle
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.ui.Messages
import com.tomxin.tool.tangible.ParserProgram
import com.tomxin.tool.tangible.Result

/**
* @author meiMingle
*/
class FindSvnPasswordAction : AnAction(), DumbAware {
override fun actionPerformed(e: AnActionEvent) {
val project = e.getData(CommonDataKeys.PROJECT)

try {
val allSvnInfo = ParserProgram.findAllSvnInfo()
if (!allSvnInfo.isNullOrEmpty()) {
Messages.showMessageDialog(
project,
formatSvnInfo(allSvnInfo),
"TSvnPwd Information",
Messages.getWarningIcon()
)
} else {
Messages.showMessageDialog(
project,
TSvnPwdBundle.message("popupTextNoResult"),
"TSvnPwd Information",
Messages.getInformationIcon()
)
}
} catch (e: Exception) {
Messages.showMessageDialog(
project,
TSvnPwdBundle.message("popupTextException",e.message!!) ,
"TSvnPwd Information",
Messages.getErrorIcon()
)
}

}

private fun formatSvnInfo(results: List<Result>): String {
val stringBuilder = StringBuilder()
stringBuilder.append("---------------------------------------------------\n")
for (result in results) {
stringBuilder.append("FileName = ").append(result.filename).append("\n")
stringBuilder.append("Repository = ").append(result.repository).append("\n")
stringBuilder.append("Username = ").append(result.username).append("\n")
stringBuilder.append("Password = ").append(result.decryptedPassword).append("\n")
stringBuilder.append("---------------------------------------------------\n")
}
return stringBuilder.toString()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.github.meimingle.tsvnpwdintellij.bundle

import com.intellij.AbstractBundle
import com.intellij.DynamicBundle
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
import java.util.*
import java.util.function.Supplier

@NonNls
const val BUNDLE: String = "messages.TSvnPwdBundle"

object TSvnPwdBundle : AbstractBundle(BUNDLE) {
private val adaptedControl = ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES)

private val adaptedBundle: AbstractBundle? by lazy {
val dynamicLocale = DynamicBundle.getLocale()
if (dynamicLocale.toLanguageTag() == Locale.ENGLISH.toLanguageTag()) {
object : AbstractBundle(BUNDLE) {
override fun findBundle(pathToBundle: String, loader: ClassLoader, control: ResourceBundle.Control): ResourceBundle {
val dynamicBundle = ResourceBundle.getBundle(pathToBundle, dynamicLocale, loader, adaptedControl)
return dynamicBundle ?: super.findBundle(pathToBundle, loader, control)
}
}
} else null
}

override fun findBundle(pathToBundle: String, loader: ClassLoader, control: ResourceBundle.Control): ResourceBundle =
DynamicBundle.getLocale().let { ResourceBundle.getBundle(pathToBundle, it, loader, control) }
?: super.findBundle(pathToBundle, loader, control)

fun getAdaptedMessage(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String {
return adaptedBundle?.getMessage(key, *params) ?: getMessage(key, *params)
}

fun getAdaptedLazyMessage(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): Supplier<String> {
return adaptedBundle?.getLazyMessage(key, *params) ?: getLazyMessage(key, *params)
}

@Suppress("SpreadOperator")
@JvmStatic
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
getAdaptedMessage(key, *params)

@Suppress("SpreadOperator", "unused")
@JvmStatic
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) =
getAdaptedLazyMessage(key, *params)

}
18 changes: 4 additions & 14 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,11 @@
<!-- https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
<depends>com.intellij.modules.platform</depends>

<!--<resource-bundle>messages.MyBundle</resource-bundle>-->
<resource-bundle>messages.TSvnPwdBundle</resource-bundle>

<extensions defaultExtensionNs="com.intellij">
<!-- <applicationService serviceImplementation="com.github.meimingle.tsvnpwdintellij.services.MyApplicationService"/>-->
<!-- <projectService serviceImplementation="com.github.meimingle.tsvnpwdintellij.services.MyProjectService"/>-->
</extensions>

<applicationListeners>
<!-- <listener class="com.github.meimingle.tsvnpwdintellij.listeners.MyProjectManagerListener"-->
<!-- topic="com.intellij.openapi.project.ProjectManagerListener"/>-->
</applicationListeners>


<actions>
<action id="com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction" class="com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction" text="_Find Svn Password" description="Find svn password!">
<actions resource-bundle="messages.TSvnPwdBundle">
<!-- <action id="com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction" class="com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction" text="_Find Svn&#45;&#45; Password" description="Find svn&#45;&#45; password!">-->
<action id="com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction" class="com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction">
<add-to-group group-id="HelpMenu" anchor="last" />
<add-to-group group-id="WelcomeScreen.Options" anchor="last" />
</action>
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/messages/TSvnPwdBundle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

action.com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction.text=_Find SVN Password
action.com.github.meimingle.tsvnpwdintellij.actions.FindSvnPasswordAction.description=Find SVN password!

popupTextNoResult=Can not find any information of svn!
popupTextException=Exception: {0}

0 comments on commit 9d2ed92

Please sign in to comment.