|
1 | 1 | package com.intellij.plugin.powershell.ide.debugger
|
2 | 2 |
|
3 |
| -import com.intellij.ide.highlighter.XmlFileType |
| 3 | +import com.intellij.idea.ActionsBundle |
| 4 | +import com.intellij.openapi.actionSystem.AnAction |
| 5 | +import com.intellij.openapi.actionSystem.AnActionEvent |
4 | 6 | import com.intellij.openapi.fileEditor.FileDocumentManager
|
5 | 7 | import com.intellij.openapi.project.Project
|
6 | 8 | import com.intellij.openapi.vfs.VirtualFile
|
7 | 9 | import com.intellij.plugin.powershell.PowerShellFileType
|
8 | 10 | import com.intellij.plugin.powershell.ide.MessagesBundle
|
9 | 11 | import com.intellij.psi.PsiDocumentManager
|
| 12 | +import com.intellij.ui.components.AnActionLink |
| 13 | +import com.intellij.ui.components.JBTextField |
| 14 | +import com.intellij.ui.components.Label |
| 15 | +import com.intellij.util.ui.JBUI |
| 16 | +import com.intellij.xdebugger.XDebuggerManager |
10 | 17 | import com.intellij.xdebugger.breakpoints.XBreakpointProperties
|
| 18 | +import com.intellij.xdebugger.breakpoints.XLineBreakpoint |
11 | 19 | import com.intellij.xdebugger.breakpoints.XLineBreakpointType
|
| 20 | +import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel |
| 21 | +import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider |
| 22 | +import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase |
| 23 | +import java.awt.BorderLayout |
| 24 | +import java.awt.Component |
| 25 | +import java.awt.Dimension |
| 26 | +import javax.swing.* |
12 | 27 |
|
13 |
| -//XsltDebuggerBundle.message("title.xslt.breakpoints") |
14 | 28 | class PowerShellBreakpointType : XLineBreakpointType<XBreakpointProperties<*>>("powershell", MessagesBundle.message("powershell.debugger.breakpoints.title")) {
|
15 | 29 | override fun canPutAt(file: VirtualFile, line: Int, project: Project): Boolean {
|
16 | 30 | val document = FileDocumentManager.getInstance().getDocument(file) ?: return false
|
17 | 31 |
|
18 | 32 | val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document) ?: return false
|
19 | 33 | val fileType = psiFile.fileType
|
20 |
| - if (fileType != PowerShellFileType.INSTANCE) { |
21 |
| - return false |
22 |
| - } |
23 |
| - return true |
| 34 | + return fileType is PowerShellFileType |
24 | 35 | }
|
| 36 | + |
25 | 37 | override fun createBreakpointProperties(file: VirtualFile, line: Int): XBreakpointProperties<*>? {
|
26 | 38 | return null
|
27 | 39 | }
|
| 40 | + |
| 41 | + override fun getEditorsProvider( |
| 42 | + breakpoint: XLineBreakpoint<XBreakpointProperties<*>>, |
| 43 | + project: Project |
| 44 | + ): XDebuggerEditorsProvider { |
| 45 | + return PowerShellDebuggerEditorsProvider(XDebuggerManager.getInstance(project).currentSession, "BPTYPE") |
| 46 | + } |
| 47 | + |
| 48 | + |
| 49 | + /*override fun createCustomConditionsPanel(): XBreakpointCustomPropertiesPanel<XLineBreakpoint<XBreakpointProperties<*>>> { |
| 50 | + return CollectionBreakpointPropertiesPanel() |
| 51 | + }*/ |
| 52 | +} |
| 53 | + |
| 54 | +class CollectionBreakpointPropertiesPanel : XBreakpointCustomPropertiesPanel<XLineBreakpoint<XBreakpointProperties<*>>>() { |
| 55 | + private var myClsName: String? = null |
| 56 | + private var myFieldName: String? = "Condition:" |
| 57 | + private var mySaveCollectionHistoryCheckBox: JCheckBox? = null |
| 58 | + |
| 59 | + override fun getComponent(): JComponent { |
| 60 | + |
| 61 | + val box = Box.createVerticalBox() |
| 62 | + |
| 63 | + var panel: JPanel = JBUI.Panels.simplePanel() |
| 64 | + //panel.add(JTextField()) |
| 65 | + val textField = JBTextField() |
| 66 | + val label = Label("Condition:").apply { |
| 67 | + labelFor = textField |
| 68 | + alignmentX = Component.LEFT_ALIGNMENT |
| 69 | + } |
| 70 | + box.add(label) |
| 71 | + box.add(textField) |
| 72 | + panel.add(box) |
| 73 | + |
| 74 | + return panel |
| 75 | + } |
| 76 | + |
| 77 | + override fun saveTo(breakpoint: XLineBreakpoint<XBreakpointProperties<*>>) { |
| 78 | + /* val changed = |
| 79 | + breakpoint.getProperties().SHOULD_SAVE_COLLECTION_HISTORY !== mySaveCollectionHistoryCheckBox!!.isSelected |
| 80 | + breakpoint.getProperties().SHOULD_SAVE_COLLECTION_HISTORY = mySaveCollectionHistoryCheckBox!!.isSelected*/ |
| 81 | + /*if (true) { |
| 82 | + (breakpoint as XBreakpointBase<*, *, *>).fireBreakpointChanged() |
| 83 | + }*/ |
| 84 | + } |
| 85 | + |
| 86 | + override fun loadFrom(breakpoint: XLineBreakpoint<XBreakpointProperties<*>>) { |
| 87 | + /*val properties = breakpoint.getProperties() |
| 88 | + myClsName = properties.myClassName |
| 89 | + myFieldName = properties.myFieldName |
| 90 | + mySaveCollectionHistoryCheckBox!!.isSelected = properties.SHOULD_SAVE_COLLECTION_HISTORY*/ |
| 91 | + } |
| 92 | + |
| 93 | + private inner class MyShowCollectionHistoryAction : AnAction() { |
| 94 | + override fun actionPerformed(e: AnActionEvent) { |
| 95 | + val clsName = myClsName |
| 96 | + val fieldName = myFieldName |
| 97 | + if (clsName == null || fieldName == null) { |
| 98 | + return |
| 99 | + } |
| 100 | + val project = getEventProject(e) ?: return |
| 101 | + val session = XDebuggerManager.getInstance(project).currentSession ?: return |
| 102 | + //DebuggerUtilsEx.addCollectionHistoryTab(session, clsName, fieldName, null) |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + companion object { |
| 107 | + private const val PREFERRED_PANEL_HEIGHT = 40 |
| 108 | + } |
28 | 109 | }
|
0 commit comments