Skip to content

Commit 216b16f

Browse files
committed
Replace deprecated code and update to 252
1 parent 82be552 commit 216b16f

File tree

9 files changed

+34
-31
lines changed

9 files changed

+34
-31
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ jobs:
6363
- name: Build Plugin
6464
run: ./gradlew :plugin:buildPlugin
6565

66-
# - name: Verify Plugin
67-
# run: ./gradlew runPluginVerifier
66+
- name: Verify Plugin
67+
run: ./gradlew runPluginVerifier
6868

6969
- name: Upload artifact
7070
uses: actions/upload-artifact@v4

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
pluginName = intellij-pdf-viewer
22
group = com.firsttimeinforever.intellij.pdf.viewer
3-
version = 0.17.1-alpha.3
3+
version = 0.17.1-alpha.4
44

55
# To run with AS 2021.3.1 Canary 5
66
#platformVersion = 213.6777.52
77

88
#IntelliJ IDEA 2021.1.2 Preview
9-
platformVersion = 2025.1
9+
platformVersion = 2025.2
1010
pluginSinceVersion = 241
11-
pluginVerifierIdeVersions = 241, 251
11+
pluginVerifierIdeVersions = 241, 252
1212

13-
texifyVersion = 0.10.4
13+
texifyVersion = 0.11.2
1414

1515
kotlinVersion = 2.2.0
1616
kotlinxSerializationJsonVersion = 1.9.0
17-
# pdfjs 5 uses URL.parse which is only available in Chrome 126 https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static#browser_compatibility but intellij 2025.1 still uses JCEF 122 (in Help > About)
17+
# pdfjs 5 uses URL.parse which is only available in Chrome 126 https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static#browser_compatibility but intellij 2025.2 still uses JCEF 122 (in Help > About)
1818
#pdfjsVersion = 5.3.93
1919
pdfjsVersion = 4.10.38
2020

plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/actions/PdfActionUtils.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.firsttimeinforever.intellij.pdf.viewer.actions
33
import com.intellij.ide.DataManager
44
import com.intellij.ide.ui.customization.CustomActionsSchema
55
import com.intellij.openapi.actionSystem.*
6+
import com.intellij.openapi.actionSystem.ex.ActionUtil
67
import java.awt.Component
78
import javax.swing.JComponent
89

@@ -22,14 +23,16 @@ internal object PdfActionUtils {
2223

2324
fun performAction(action: AnAction, component: Component) {
2425
val context = DataManager.getInstance().getDataContext(component)
25-
action.actionPerformed(
26+
ActionUtil.performAction(
27+
action,
2628
AnActionEvent(
27-
null,
2829
context,
29-
ActionPlaces.UNKNOWN,
3030
Presentation(),
31-
ActionManager.getInstance(),
32-
0
31+
ActionPlaces.UNKNOWN,
32+
ActionUiKind.TOOLBAR,
33+
null,
34+
0,
35+
ActionManager.getInstance()
3336
)
3437
)
3538
}

plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/actions/PdfToggleAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class PdfToggleAction(viewModeAwareness: ViewModeAwareness = ViewModeAw
1717
base.update(event)
1818
}
1919

20-
private inner class StubAction(viewModeAwareness: ViewModeAwareness) : PdfAction(viewModeAwareness) {
20+
private class StubAction(viewModeAwareness: ViewModeAwareness) : PdfAction(viewModeAwareness) {
2121
override fun actionPerformed(event: AnActionEvent) {
2222
throw IllegalStateException("This method should not be called")
2323
}

plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/report/PdfErrorReportSubmitter.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.firsttimeinforever.intellij.pdf.viewer.report
22

33
import com.firsttimeinforever.intellij.pdf.viewer.PdfViewerBundle
4-
import com.intellij.diagnostic.IdeaReportingEvent
54
import com.intellij.ide.DataManager
65
import com.intellij.ide.plugins.IdeaPluginDescriptor
76
import com.intellij.idea.IdeaLogger
@@ -42,10 +41,9 @@ internal class PdfErrorReportSubmitter : ErrorReportSubmitter() {
4241

4342
private fun createEvents(events: Array<out IdeaLoggingEvent>, additionalInfo: String?): List<SentryEvent> {
4443
return events
45-
.filterIsInstance<IdeaReportingEvent>()
4644
.map { ideaEvent ->
4745
SentryEvent().apply {
48-
this.message = Message().apply { this.message = additionalInfo ?: ideaEvent.originalThrowableText }
46+
this.message = Message().apply { this.message = additionalInfo ?: ideaEvent.throwableText }
4947
this.level = SentryLevel.ERROR
5048
this.throwable = ideaEvent.throwable
5149

plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/ui/editor/view/PdfJcefPreviewController.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.intellij.openapi.project.Project
2929
import com.intellij.openapi.util.Disposer
3030
import com.intellij.openapi.util.registry.Registry
3131
import com.intellij.openapi.vfs.VirtualFile
32+
import com.intellij.ui.JBColor
3233
import com.intellij.ui.jcef.JCEFHtmlPanel
3334
import com.intellij.util.ui.UIUtil
3435
import io.netty.handler.codec.http.QueryStringDecoder
@@ -39,7 +40,7 @@ import org.cef.callback.CefContextMenuParams
3940
import org.cef.callback.CefMenuModel
4041
import org.cef.handler.CefContextMenuHandlerAdapter
4142
import java.awt.Color
42-
import java.net.URL
43+
import java.net.URI
4344
import java.util.concurrent.atomic.AtomicBoolean
4445

4546
class PdfJcefPreviewController(val project: Project, val virtualFile: VirtualFile) :
@@ -90,7 +91,7 @@ class PdfJcefPreviewController(val project: Project, val virtualFile: VirtualFil
9091
if (!viewLoaded || cefBrowser == null) return null
9192
val urlDecoder = QueryStringDecoder(cefBrowser.url)
9293
val file = urlDecoder.parameters()?.get("file")?.get(0) ?: return null
93-
return URL(URL(cefBrowser.url), file).toString()
94+
return URI(cefBrowser.url).resolve(file).toString()
9495
}
9596

9697
override fun onBeforeContextMenu(cefBrowser: CefBrowser?, frame: CefFrame?, params: CefContextMenuParams?, model: CefMenuModel?) {
@@ -203,9 +204,9 @@ class PdfJcefPreviewController(val project: Project, val virtualFile: VirtualFil
203204
return when {
204205
PdfViewerSettings.instance.useCustomColors -> PdfViewerSettings.instance.run {
205206
ViewTheme.create(
206-
Color(customBackgroundColor),
207-
Color(customForegroundColor),
208-
Color(customIconColor),
207+
JBColor(customBackgroundColor, customBackgroundColor),
208+
JBColor(customForegroundColor, customForegroundColor),
209+
JBColor(customIconColor, customIconColor),
209210
colorInvertIntensity
210211
)
211212
}

plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/ui/editor/view/controls/PdfSearchPanel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.intellij.find.SearchTextArea
99
import com.intellij.icons.AllIcons
1010
import com.intellij.openapi.Disposable
1111
import com.intellij.openapi.actionSystem.*
12+
import com.intellij.openapi.actionSystem.ex.ActionUtil
1213
import com.intellij.openapi.project.DumbAwareAction
1314
import com.intellij.openapi.project.DumbAwareToggleAction
1415
import com.intellij.openapi.wm.IdeFocusManager
@@ -56,8 +57,8 @@ class PdfSearchPanel(private val viewComponent: PdfEditorViewComponent): JPanel(
5657

5758
private val findForwardAction = ActionManager.getInstance().getAction("pdf.viewer.FindForwardAction")!!
5859
private val findBackwardAction = ActionManager.getInstance().getAction("pdf.viewer.FindBackwardAction")!!
59-
private val findForwardOnEnterAction = DumbAwareAction.create(findForwardAction::actionPerformed)
60-
private val findBackwardOnShiftEnterAction = DumbAwareAction.create(findBackwardAction::actionPerformed)
60+
private val findForwardOnEnterAction = DumbAwareAction.create { ActionUtil.performAction(findForwardAction, it) }
61+
private val findBackwardOnShiftEnterAction = DumbAwareAction.create { ActionUtil.performAction(findBackwardAction, it) }
6162

6263
init {
6364
layout = MigLayout("flowx, gap 8, ins 0, fillx, hidemode 3")

plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/ui/widgets/PdfStatusBarProjectManagerListener.kt renamed to plugin/src/main/kotlin/com/firsttimeinforever/intellij/pdf/viewer/ui/widgets/PdfStatusBarProjectActivity.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
package com.firsttimeinforever.intellij.pdf.viewer.ui.widgets
22

3+
import com.intellij.openapi.components.service
34
import com.intellij.openapi.diagnostic.logger
45
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
56
import com.intellij.openapi.fileEditor.FileEditorManagerListener
67
import com.intellij.openapi.project.Project
7-
import com.intellij.openapi.project.ProjectManagerListener
8+
import com.intellij.openapi.startup.ProjectActivity
89
import com.intellij.openapi.wm.impl.status.widget.StatusBarWidgetsManager
910

10-
internal class PdfStatusBarProjectManagerListener : ProjectManagerListener {
11-
override fun projectOpened(project: Project) {
11+
internal class PdfStatusBarProjectActivity : ProjectActivity {
12+
override suspend fun execute(project: Project) {
1213
logger.debug("Registering new FileEditorManagerListener for newly opened project")
1314
project.messageBus.connect().subscribe(
1415
FileEditorManagerListener.FILE_EDITOR_MANAGER,
1516
object : FileEditorManagerListener {
1617
override fun selectionChanged(event: FileEditorManagerEvent) {
1718
logger.debug("Selection changed")
18-
val targetFactory = StatusBarWidgetsManager::class.java
19-
project.getServiceIfCreated(targetFactory)?.run {
19+
@Suppress("IncorrectServiceRetrieving") // Incorrect: PdfStatusBarProjectManagerListener is a project service
20+
project.service<StatusBarWidgetsManager>().run {
2021
logger.debug("Updating widget")
2122
updateWidget(PdfDocumentPageStatusBarWidgetFactory::class.java)
2223
}
@@ -26,6 +27,6 @@ internal class PdfStatusBarProjectManagerListener : ProjectManagerListener {
2627
}
2728

2829
companion object {
29-
private val logger = logger<PdfStatusBarProjectManagerListener>()
30+
private val logger = logger<PdfStatusBarProjectActivity>()
3031
}
3132
}

plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
implementation="com.firsttimeinforever.intellij.pdf.viewer.ui.widgets.PdfDocumentPageStatusBarWidgetFactory"/>
3131

3232
<customizableActionGroupProvider implementation="com.firsttimeinforever.intellij.pdf.viewer.actions.PdfCustomizableActionGroupProvider"/>
33+
<postStartupActivity implementation="com.firsttimeinforever.intellij.pdf.viewer.ui.widgets.PdfStatusBarProjectActivity"/>
3334
</extensions>
3435

3536
<applicationListeners>
36-
<listener class="com.firsttimeinforever.intellij.pdf.viewer.ui.widgets.PdfStatusBarProjectManagerListener"
37-
topic="com.intellij.openapi.project.ProjectManagerListener"/>
3837
<listener class="com.firsttimeinforever.intellij.pdf.viewer.settings.PdfViewerInvertColorsListener"
3938
topic="com.intellij.openapi.editor.colors.EditorColorsListener"/>
4039
</applicationListeners>

0 commit comments

Comments
 (0)