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
6 changed files
with
123 additions
and
63 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
49 changes: 0 additions & 49 deletions
49
src/main/java/com/github/meimingle/tsvnpwdintellij/actions/FindSvnPasswordAction.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
src/main/kotlin/com/github/meimingle/tsvnpwdintellij/actions/FindSvnPasswordAction.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,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() | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/com/github/meimingle/tsvnpwdintellij/bundle/TSvnPwdBundle.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,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) | ||
|
||
} |
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
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} |