Skip to content

Commit

Permalink
[ bridge info ] Use dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Apr 21, 2019
1 parent dad43cf commit 253b6d0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions res/META-INF/change-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ul>
<li>Fix <code>NoClassDefError</code> when Rust plugin is not installed (#18)</li>
<li>Access native bridge information</li>
<li>Live Preview is no longer <code>DumbAware</code></li>
</ul>
0.2.3<br/>
<ul>
Expand Down
19 changes: 11 additions & 8 deletions src/rs/pest/action/tools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.ui.DialogBuilder
import com.intellij.openapi.ui.popup.Balloon
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.psi.util.PsiTreeUtil
Expand All @@ -16,17 +17,15 @@ import rs.pest.livePreview.livePreview

class PestViewInfoAction : AnAction(), DumbAware {
override fun actionPerformed(e: AnActionEvent) {
val editor = CommonDataKeys.EDITOR.getData(e.dataContext) ?: return
val component = PestIdeBridgeInfoImpl().component
JBPopupFactory.getInstance()
.createDialogBalloonBuilder(component, PestBundle.message("pest.actions.info.title"))
.setHideOnClickOutside(true)
.createBalloon()
.showInCenterOf(editor.component)
DialogBuilder()
.title(PestBundle.message("pest.actions.info.title"))
.centerPanel(component)
.show()
}
}

class PestLivePreviewAction : AnAction(), DumbAware {
class PestLivePreviewAction : AnAction() {
override fun update(e: AnActionEvent) {
super.update(e)
val psiFile = CommonDataKeys.PSI_FILE.getData(e.dataContext) as? PestFile ?: return
Expand All @@ -46,7 +45,11 @@ class PestLivePreviewAction : AnAction(), DumbAware {
?: return
lateinit var balloon: Balloon
val popup = RuleSelector().apply {
file.availableRules.map { object { override fun toString() = it } }.forEach(ruleCombo::addItem)
file.availableRules.map {
object {
override fun toString() = it
}
}.forEach(ruleCombo::addItem)
ruleCombo.selectedIndex = 0
okButton.addActionListener {
balloon.hide(true)
Expand Down
2 changes: 1 addition & 1 deletion src/rs/pest/action/ui/ui-impl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PestIdeBridgeInfoImpl : PestIdeBridgeInfo() {
val component get() = mainPanel

companion object {
private val info by lazy { Lib(PestUtil(114514 * 10)).crateInfo() }
val info by lazy { Lib(PestUtil(114514 * 50)).crateInfo() }
}

init {
Expand Down
6 changes: 5 additions & 1 deletion src/rs/pest/error/error-report.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import org.eclipse.egit.github.core.service.IssueService
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.PropertyKey
import rs.pest.PEST_PLUGIN_ID
import rs.pest.action.ui.PestIdeBridgeInfoImpl
import java.awt.Component
import java.io.IOException
import java.io.ObjectInputStream
Expand Down Expand Up @@ -231,6 +232,7 @@ class GitHubErrorBean(
val message: String) {
val exceptionHash: String
val stackTrace: String

init {
val trace = throwable.stackTrace
exceptionHash = Arrays.hashCode(trace).toString()
Expand All @@ -248,7 +250,8 @@ class GitHubErrorBean(
* Messages and strings used by the error reporter
*/
private object ErrorReportBundle {
@NonNls private const val BUNDLE = "rs.pest.error.report-bundle"
@NonNls
private const val BUNDLE = "rs.pest.error.report-bundle"
private val bundle: ResourceBundle by lazy { ResourceBundle.getBundle(BUNDLE) }

@JvmStatic
Expand Down Expand Up @@ -282,6 +285,7 @@ private fun getKeyValuePairs(
"error.description" to error.description,
"Plugin Name" to error.pluginName,
"Plugin Version" to error.pluginVersion,
"Bundled Pest Version" to PestIdeBridgeInfoImpl.info.version,
"OS Name" to SystemInfo.OS_NAME,
"Java Version" to SystemInfo.JAVA_VERSION,
"App Name" to namesInfo.productName,
Expand Down

0 comments on commit 253b6d0

Please sign in to comment.