Skip to content

Commit

Permalink
#262 | Added collapse/expand all actions for TS and BS views
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Mar 6, 2023
1 parent b3dc21f commit 0ee9c14
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
1 change: 1 addition & 0 deletions resources/META-INF/plugin-release-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<li><i>Feature:</i> Improved PSI cache usage (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/258" target="_blank" rel="nofollow">#258</a>)</li>
<li><i>Feature:</i> Improved performance of the Global Meta Model and TS LineMarker (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/257" target="_blank" rel="nofollow">#257</a>)</li>
<li><i>Feature:</i> IDEA modules by default will be stored in the <code>/.idea/idea-modules</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/259" target="_blank" rel="nofollow">#259</a>)</li>
<li><i>Feature:</i> Added collapse/expand all actions for TS and BS views (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/262" target="_blank" rel="nofollow">#262</a>)</li>
<li><i>Bug Fix:</i> Console is not releasing Document on Project dispose (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/260" target="_blank" rel="nofollow">#260</a>)</li>
<li><i>Bug Fix:</i> Fixed Ant targets registration after Project Refresh</li>
<li><i>Other:</i> Improved cleanup on Project dispose</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
package com.intellij.idea.plugin.hybris.toolwindow.system.bean.components

import com.intellij.ide.IdeBundle
import com.intellij.idea.plugin.hybris.system.bean.meta.BSChangeListener
import com.intellij.idea.plugin.hybris.system.bean.meta.BSGlobalMetaModel
import com.intellij.idea.plugin.hybris.system.bean.meta.impl.BSMetaModelAccessImpl
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.forms.BSMetaBeanView
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.forms.BSMetaEnumView
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.tree.BSTree
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.tree.BSTreeModel
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.view.BSViewSettings
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.tree.nodes.*
import com.intellij.idea.plugin.hybris.toolwindow.system.bean.view.BSViewSettings
import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.ui.OnePixelSplitter
import com.intellij.ui.components.JBPanelWithEmptyText
import com.intellij.ui.components.JBScrollPane
Expand All @@ -38,8 +36,8 @@ import javax.swing.event.TreeSelectionListener
class BSTreePanel(
private val myProject: Project,
) : OnePixelSplitter(false, 0.25f), Disposable {
private var myTree = BSTree(myProject)
private var myDefaultPanel = JBPanelWithEmptyText().withEmptyText(IdeBundle.message("empty.text.nothing.selected"))
val tree = BSTree(myProject)
private val myDefaultPanel = JBPanelWithEmptyText().withEmptyText(IdeBundle.message("empty.text.nothing.selected"))
private val myMetaEnumView: BSMetaEnumView by lazy {
BSMetaEnumView(
myProject
Expand All @@ -53,20 +51,22 @@ class BSTreePanel(
private val myTreeSelectionListener: TreeSelectionListener = treeSelectionListener()

init {
firstComponent = JBScrollPane(myTree)
firstComponent = JBScrollPane(tree)
secondComponent = myDefaultPanel

myTree.addTreeSelectionListener(myTreeSelectionListener)
tree.addTreeSelectionListener(myTreeSelectionListener)

Disposer.register(this, tree)
}

fun update(changeType: BSViewSettings.ChangeType) {
secondComponent = myDefaultPanel;

myTree.update(changeType)
tree.update(changeType)
}

override fun dispose() {
myTree.removeTreeSelectionListener { myTreeSelectionListener }
tree.removeTreeSelectionListener { myTreeSelectionListener }
}

private fun treeSelectionListener() = TreeSelectionListener { tls ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.intellij.idea.plugin.hybris.toolwindow.system.bean.view

import com.intellij.icons.AllIcons
import com.intellij.ide.CommonActionsManager
import com.intellij.ide.IdeBundle
import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message
import com.intellij.idea.plugin.hybris.system.bean.meta.BSChangeListener
Expand Down Expand Up @@ -62,8 +63,12 @@ class BSView(val myProject: Project) : SimpleToolWindowPanel(false, true), Dispo
}

private fun installToolbar() {
val actionsManager = CommonActionsManager.getInstance()
val toolbar = with(DefaultActionGroup()) {
add(myBeansViewActionGroup)
addSeparator()
add(actionsManager.createExpandAllHeaderAction(myTreePane.tree))
add(actionsManager.createCollapseAllHeaderAction(myTreePane.tree))
ActionManager.getInstance().createActionToolbar("HybrisBSView", this, false)
}
toolbar.targetComponent = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
package com.intellij.idea.plugin.hybris.toolwindow.system.type.components

import com.intellij.ide.IdeBundle
import com.intellij.idea.plugin.hybris.system.type.meta.TSChangeListener
import com.intellij.idea.plugin.hybris.toolwindow.system.type.forms.*
import com.intellij.idea.plugin.hybris.toolwindow.system.type.tree.TSTree
import com.intellij.idea.plugin.hybris.toolwindow.system.type.tree.TSTreeModel
import com.intellij.idea.plugin.hybris.toolwindow.system.type.tree.nodes.*
import com.intellij.idea.plugin.hybris.toolwindow.system.type.view.TSViewSettings
import com.intellij.idea.plugin.hybris.system.type.meta.TSGlobalMetaModel
import com.intellij.idea.plugin.hybris.system.type.meta.impl.TSMetaModelAccessImpl
import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.ui.OnePixelSplitter
import com.intellij.ui.components.JBPanelWithEmptyText
import com.intellij.ui.components.JBScrollPane
Expand All @@ -37,8 +35,8 @@ import javax.swing.event.TreeSelectionListener
class TSTreePanel(
private val myProject: Project,
) : OnePixelSplitter(false, 0.25f), Disposable {
private var myTree = TSTree(myProject)
private var myDefaultPanel = JBPanelWithEmptyText().withEmptyText(IdeBundle.message("empty.text.nothing.selected"))
val tree = TSTree(myProject)
private val myDefaultPanel = JBPanelWithEmptyText().withEmptyText(IdeBundle.message("empty.text.nothing.selected"))
private val myMetaItemView: TSMetaItemView by lazy { TSMetaItemView(myProject) }
private val myMetaEnumView: TSMetaEnumView by lazy { TSMetaEnumView(myProject) }
private val myMetaAtomicView: TSMetaAtomicView by lazy { TSMetaAtomicView(myProject) }
Expand All @@ -48,20 +46,22 @@ class TSTreePanel(
private val myTreeSelectionListener: TreeSelectionListener = treeSelectionListener()

init {
firstComponent = JBScrollPane(myTree)
firstComponent = JBScrollPane(tree)
secondComponent = myDefaultPanel

myTree.addTreeSelectionListener(myTreeSelectionListener)
tree.addTreeSelectionListener(myTreeSelectionListener)

Disposer.register(this, tree)
}

fun update(changeType: TSViewSettings.ChangeType) {
secondComponent = myDefaultPanel;

myTree.update(changeType)
tree.update(changeType)
}

override fun dispose() {
myTree.removeTreeSelectionListener { myTreeSelectionListener }
tree.removeTreeSelectionListener { myTreeSelectionListener }
}

private fun treeSelectionListener() = TreeSelectionListener { tls ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.intellij.idea.plugin.hybris.toolwindow.system.type.view

import com.intellij.icons.AllIcons
import com.intellij.ide.CommonActionsManager
import com.intellij.ide.IdeBundle
import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message
import com.intellij.idea.plugin.hybris.system.type.meta.TSChangeListener
Expand Down Expand Up @@ -62,8 +63,12 @@ class TSView(val myProject: Project) : SimpleToolWindowPanel(false, true), Dispo
}

private fun installToolbar() {
val actionsManager = CommonActionsManager.getInstance()
val toolbar = with(DefaultActionGroup()) {
add(myItemsViewActionGroup)
addSeparator()
add(actionsManager.createExpandAllHeaderAction(myTreePane.tree))
add(actionsManager.createCollapseAllHeaderAction(myTreePane.tree))
ActionManager.getInstance().createActionToolbar("HybrisTSView", this, false)
}
toolbar.targetComponent = this
Expand Down

0 comments on commit 0ee9c14

Please sign in to comment.