1
0
mirror of https://github.com/chylex/IntelliJ-Rainbow-Brackets.git synced 2025-04-11 03:15:49 +02:00

Update notification

This commit is contained in:
张志豪 2020-04-05 13:26:50 +08:00
parent 011a0fdc85
commit 2f3ded5990
6 changed files with 19 additions and 68 deletions
src/main

View File

@ -2,14 +2,12 @@ package com.github.izhangzhihao.rainbow.brackets
import com.intellij.notification.*
import com.intellij.notification.impl.NotificationsManagerImpl
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.popup.Balloon
import com.intellij.openapi.wm.WindowManager
import com.intellij.ui.BalloonLayoutData
import com.intellij.ui.awt.RelativePoint
import java.awt.Point
import javax.swing.event.HyperlinkEvent
fun createNotification(title: String, content: String, displayId: String,
type: NotificationType, listener: NotificationListener): Notification {
@ -40,12 +38,4 @@ fun showFullNotification(project: Project, notification: Notification) {
} catch (e: Exception) {
notification.notify(project)
}
}
class SettingsOpeningListener(val project: Project, private val nameToSelect: String) : NotificationListener.Adapter() {
override fun hyperlinkActivated(notifi: Notification, event: HyperlinkEvent) {
if (!project.isDisposed) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, nameToSelect)
}
}
}

View File

@ -1,6 +1,5 @@
package com.github.izhangzhihao.rainbow.brackets.activity
package com.github.izhangzhihao.rainbow.brackets
import com.github.izhangzhihao.rainbow.brackets.RainbowHighlighter
import com.intellij.openapi.editor.colors.EditorColorsListener
import com.intellij.openapi.editor.colors.EditorColorsScheme

View File

@ -1,15 +1,14 @@
package com.github.izhangzhihao.rainbow.brackets.activity
package com.github.izhangzhihao.rainbow.brackets
import com.github.izhangzhihao.rainbow.brackets.createNotification
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings
import com.github.izhangzhihao.rainbow.brackets.showFullNotification
import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.notification.NotificationListener
import com.intellij.notification.NotificationListener.UrlOpeningListener
import com.intellij.notification.NotificationType
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import org.intellij.lang.annotations.Language
class RainbowUpdateNotifyActivity : StartupActivity {
var updated: Boolean = false
@ -30,7 +29,7 @@ class RainbowUpdateNotifyActivity : StartupActivity {
updateContent,
channel,
NotificationType.INFORMATION,
NotificationListener.URL_OPENING_LISTENER
UrlOpeningListener(false)
)
showFullNotification(project, notification)
}
@ -38,15 +37,21 @@ class RainbowUpdateNotifyActivity : StartupActivity {
companion object {
private val version = RainbowSettings.instance.version
private var channel = "izhangzhihao.rainbow.brackets"
@Language("HTML")
private val updateContent = """
<br/>
Thank you for downloading 🌈<b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets">Rainbow Brackets</a></b>!<br>
Sponsored by <a href="https://codestream.com/?utm_source=jbmarket&utm_medium=banner&utm_campaign=jbrainbowbrackets">CodeStream</a>.<br>
If you find this plugin helpful, <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#support-us">please support us!</a>.</b><br>
🌈Thank you for downloading <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets">Rainbow Brackets</a></b>!<br>
🎉Sponsored by <a href="https://codestream.com/?utm_source=jbmarket&utm_medium=banner&utm_campaign=jbrainbowbrackets">CodeStream</a>.<br>
👍If you find this plugin helpful, <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#support-us">please support us!</a>.</b><br>
<b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#support-us">Donate</a></b> by <b><a href="https://opencollective.com/intellij-rainbow-brackets">OpenCollective</a></b> Or AliPay/WeChatPay to <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets#sponsors">become a sponsor</a>!.</b><br>
Check out <b><a href="https://izhangzhihao.github.io/rainbow-brackets-document/">the document</a></b> for all features of this plugin.<br>
If you run into any problem, <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets/issues">feel free to raise a issue</a>.</b><br/><br>
See <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets/releases/tag/$version">changelog</a></b> for more details about this update.<br>
📝Check out <b><a href="https://izhangzhihao.github.io/rainbow-brackets-document/">the document</a></b> for all features of this plugin.<br>
🐛If you run into any problem, <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets/issues">feel free to raise a issue</a>.</b><br>
🆕See <b><a href="https://github.com/izhangzhihao/intellij-rainbow-brackets/releases/tag/$version">changelog</a></b> for more details about this update.<br>
👉Want to customize your own color scheme of Rainbow Brackets? Edit it under
<b>Settings > Editor > Color Scheme > Rainbow Brackets</b><br>
👉Other additional feature under
<b>Settings > Other Settings > Rainbow Brackets</b><br/>
Enjoy your colorful code🌈.
"""

View File

@ -1,41 +0,0 @@
package com.github.izhangzhihao.rainbow.brackets.activity
import com.github.izhangzhihao.rainbow.brackets.SettingsOpeningListener
import com.github.izhangzhihao.rainbow.brackets.createNotification
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowColorsPageFactory
import com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
class ShowCustomRainbowSchemeActivity : StartupActivity {
override fun runActivity(project: Project) {
if (!RainbowSettings.instance.isCustomNotifyShowed) {
notify(project)
}
}
companion object {
private var channel = "izhangzhihao.rainbow.brackets"
private const val notifyContent = """
Want to customize your own color scheme of Rainbow Brackets? Edit it under
<a href="#">Settings > Editor > Color Scheme > Rainbow Brackets</a>
<br/>
Check out <b><a href="https://izhangzhihao.github.io/rainbow-brackets-document/">the document</a></b> for all the features of this plugin.<br>
"""
private fun notify(project: Project) {
val notification = createNotification(
"Want to customize your own rainbow colors?",
notifyContent,
channel,
NotificationType.INFORMATION,
SettingsOpeningListener(project, RainbowColorsPageFactory().displayName)
)
Notifications.Bus.notify(notification)
RainbowSettings.instance.isCustomNotifyShowed = true
}
}
}

View File

@ -26,7 +26,6 @@ class RainbowSettings : PersistentStateComponent<RainbowSettings> {
var isRainbowifyKotlinLabel = true
var isRainbowifyKotlinFunctionLiteralBracesAndArrow = true
var isOverrideMatchedBraceAttributes = true
var isCustomNotifyShowed = false
var pressAnyKeyToRemoveTheHighlightingEffects = false
var applyColorsOfRoundForAllBrackets = false
var cycleCountOnAllBrackets = false

View File

@ -545,14 +545,13 @@
<additionalTextAttributes scheme="Default" file="colorSchemes/rainbow-color-default.xml"/>
<additionalTextAttributes scheme="Darcula" file="colorSchemes/rainbow-color-default-darcula.xml"/>
<backgroundPostStartupActivity implementation="com.github.izhangzhihao.rainbow.brackets.activity.RainbowUpdateNotifyActivity"/>
<backgroundPostStartupActivity implementation="com.github.izhangzhihao.rainbow.brackets.activity.ShowCustomRainbowSchemeActivity"/>
<backgroundPostStartupActivity implementation="com.github.izhangzhihao.rainbow.brackets.RainbowUpdateNotifyActivity"/>
<errorHandler implementation="com.github.izhangzhihao.rainbow.brackets.util.GitHubErrorReporter"/>
<highlightingPassFactory implementation="com.github.izhangzhihao.rainbow.brackets.indents.RainbowIndentsPassFactory"/>
</extensions>
<applicationListeners>
<listener class="com.github.izhangzhihao.rainbow.brackets.activity.RainbowColorsSchemeListener" topic="com.intellij.openapi.editor.colors.EditorColorsListener"/>
<listener class="com.github.izhangzhihao.rainbow.brackets.RainbowColorsSchemeListener" topic="com.intellij.openapi.editor.colors.EditorColorsListener"/>
</applicationListeners>
<actions>