Skip to content

Commit

Permalink
filter visibility by external library function
Browse files Browse the repository at this point in the history
  • Loading branch information
Chentai-Kao committed May 13, 2019
1 parent 9ab8b9e commit 9153874
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 110 deletions.
133 changes: 76 additions & 57 deletions src/main/kotlin/callgraph/CallGraphToolWindow.form
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="27dc6" binding="callGraphToolWindowContent" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="1116" height="409"/>
<xy x="20" y="20" width="1262" height="418"/>
</constraints>
<properties>
<toolTipText value=""/>
Expand Down Expand Up @@ -183,7 +183,7 @@
<grid id="38e2b" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Info">
Expand Down Expand Up @@ -433,19 +433,70 @@
</vspacer>
</children>
</grid>
<grid id="3fac4" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="67170" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Node options">
<title-color color="-8355712"/>
</border>
<children>
<component id="69ac5" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="icons/node-selection.png"/>
<text value="&lt;html&gt;&lt;b&gt;Node selection&lt;/b&gt;&lt;/html&gt;"/>
</properties>
</component>
<vspacer id="fbb9c">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="bd7f3" class="javax.swing.JComboBox" binding="nodeSelectionComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
</component>
<component id="a647e" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="icons/color.png"/>
<text value="&lt;html&gt;&lt;b&gt;Node color&lt;/b&gt;&lt;/html&gt;"/>
</properties>
</component>
<component id="6146e" class="javax.swing.JComboBox" binding="nodeColorComboBox">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
</component>
</children>
</grid>
<grid id="3fac4" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="2" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Search &amp; filters">
<border type="etched" title="Search &amp; visibility filters">
<title-color color="-8355712"/>
</border>
<children>
<vspacer id="c2264">
<constraints>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="c207b" class="javax.swing.JLabel">
Expand All @@ -459,7 +510,7 @@
</component>
<component id="265b4" class="javax.swing.JTextField" binding="searchTextField">
<constraints>
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
Expand All @@ -470,7 +521,7 @@
</component>
<component id="4a601" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="icons/filter.png"/>
Expand All @@ -479,93 +530,61 @@
</component>
<component id="ce116" class="javax.swing.JCheckBox" binding="filterAccessPublicCheckbox">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<selected value="true"/>
<text value="P&amp;ublic"/>
<text value="P&amp;ublic functions"/>
</properties>
</component>
<component id="9ae3b" class="javax.swing.JCheckBox" binding="filterAccessProtectedCheckbox">
<component id="d5c1" class="javax.swing.JCheckBox" binding="filterAccessPackageLocalCheckbox">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<selected value="true"/>
<text value="Pr&amp;otected"/>
<text value="P&amp;ackage local functions"/>
</properties>
</component>
<component id="d5c1" class="javax.swing.JCheckBox" binding="filterAccessPackageLocalCheckbox">
<component id="9ae3b" class="javax.swing.JCheckBox" binding="filterAccessProtectedCheckbox">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<selected value="true"/>
<text value="P&amp;ackage local"/>
<text value="Pr&amp;otected functions"/>
</properties>
</component>
<component id="fc6f6" class="javax.swing.JCheckBox" binding="filterAccessPrivateCheckbox">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<selected value="true"/>
<text value="&amp;Private"/>
</properties>
</component>
</children>
</grid>
<grid id="67170" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title="Node options">
<title-color color="-8355712"/>
</border>
<children>
<component id="69ac5" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="icons/node-selection.png"/>
<text value="&lt;html&gt;&lt;b&gt;Node selection&lt;/b&gt;&lt;/html&gt;"/>
<text value="&amp;Private functions"/>
</properties>
</component>
<vspacer id="fbb9c">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="bd7f3" class="javax.swing.JComboBox" binding="nodeSelectionComboBox">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
</properties>
</component>
<component id="a647e" class="javax.swing.JLabel">
<component id="8c384" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="icons/color.png"/>
<text value="&lt;html&gt;&lt;b&gt;Node color&lt;/b&gt;&lt;/html&gt;"/>
<icon value="icons/filter.png"/>
<text value="&lt;html&gt;&lt;b&gt;Ext. functions&lt;/b&gt;&lt;/html&gt;"/>
</properties>
</component>
<component id="6146e" class="javax.swing.JComboBox" binding="nodeColorComboBox">
<component id="ccaa9" class="javax.swing.JCheckBox" binding="filterExternalCheckbox">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="false"/>
<selected value="true"/>
<text value="&amp;External library functions"/>
</properties>
</component>
</children>
Expand Down
44 changes: 16 additions & 28 deletions src/main/kotlin/callgraph/CallGraphToolWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CallGraphToolWindow {
private lateinit var nodeSelectionComboBox: JComboBox<String>
private lateinit var searchTextField: JTextField
private lateinit var nodeColorComboBox: JComboBox<String>
private lateinit var filterExternalCheckbox: JCheckBox
private lateinit var filterAccessPublicCheckbox: JCheckBox
private lateinit var filterAccessProtectedCheckbox: JCheckBox
private lateinit var filterAccessPackageLocalCheckbox: JCheckBox
Expand All @@ -46,7 +47,8 @@ class CallGraphToolWindow {
private val canvasBuilder = CanvasBuilder()
private val canvas: Canvas = Canvas(this)
private val focusedMethods = mutableSetOf<PsiMethod>()
private val filterAccessCheckboxes = listOf(
private val filterCheckboxes = listOf(
this.filterExternalCheckbox,
this.filterAccessPublicCheckbox,
this.filterAccessProtectedCheckbox,
this.filterAccessPackageLocalCheckbox,
Expand Down Expand Up @@ -90,7 +92,7 @@ class CallGraphToolWindow {
this@CallGraphToolWindow.canvas.repaint()
}
})
this.filterAccessCheckboxes.forEach { it.addActionListener { this.canvas.filterAccessChangeHandler() } }
this.filterCheckboxes.forEach { it.addActionListener { this.canvas.filterChangeHandler() } }

// click handlers for buttons
this.projectScopeButton.addActionListener { projectScopeButtonHandler() }
Expand Down Expand Up @@ -123,13 +125,9 @@ class CallGraphToolWindow {
this.canvasPanel.add(this.canvas)
}

fun getContent(): JPanel {
return this.callGraphToolWindowContent
}
fun getContent() = this.callGraphToolWindowContent

fun isFocusedMethod(method: PsiMethod): Boolean {
return this.focusedMethods.contains(method)
}
fun isFocusedMethod(method: PsiMethod) = this.focusedMethods.contains(method)

fun toggleFocusedMethod(method: PsiMethod): CallGraphToolWindow {
if (this.focusedMethods.contains(method)) {
Expand Down Expand Up @@ -182,29 +180,19 @@ class CallGraphToolWindow {
return searchQuery.isNotEmpty() && text.toLowerCase().contains(searchQuery)
}

fun isNodeColorByAccess(): Boolean {
return getSelectedComboBoxOption(this.nodeColorComboBox) == ComboBoxOptions.NODE_COLOR_ACCESS
}
fun isNodeColorByAccess() = getSelectedComboBoxOption(this.nodeColorComboBox) == ComboBoxOptions.NODE_COLOR_ACCESS

fun isNodeColorByClassName(): Boolean {
return getSelectedComboBoxOption(this.nodeColorComboBox) == ComboBoxOptions.NODE_COLOR_CLASS
}
fun isNodeColorByClassName() = getSelectedComboBoxOption(this.nodeColorComboBox) == ComboBoxOptions.NODE_COLOR_CLASS

fun isFilterAccessPublicChecked(): Boolean {
return this.filterAccessPublicCheckbox.isSelected
}
fun isFilterExternalChecked() = this.filterExternalCheckbox.isSelected

fun isFilterAccessProtectedChecked(): Boolean {
return this.filterAccessProtectedCheckbox.isSelected
}
fun isFilterAccessPublicChecked() = this.filterAccessPublicCheckbox.isSelected

fun isFilterAccessPackageLocalChecked(): Boolean {
return this.filterAccessPackageLocalCheckbox.isSelected
}
fun isFilterAccessProtectedChecked() = this.filterAccessProtectedCheckbox.isSelected

fun isFilterAccessPrivateChecked(): Boolean {
return this.filterAccessPrivateCheckbox.isSelected
}
fun isFilterAccessPackageLocalChecked() = this.filterAccessPackageLocalCheckbox.isSelected

fun isFilterAccessPrivateChecked() = this.filterAccessPrivateCheckbox.isSelected

fun getCanvasSize(): Dimension = this.canvasPanel.size

Expand Down Expand Up @@ -331,7 +319,7 @@ class CallGraphToolWindow {
this.searchTextField
).forEach { (it as JComponent).isEnabled = false }
// filter-related checkboxes
this.filterAccessCheckboxes.forEach {
this.filterCheckboxes.forEach {
it.isEnabled = false
it.isSelected = true
}
Expand Down Expand Up @@ -365,7 +353,7 @@ class CallGraphToolWindow {
this.searchTextField
).forEach { (it as JComponent).isEnabled = true }
// filter-related checkboxes
this.filterAccessCheckboxes.forEach { it.isEnabled = true }
this.filterCheckboxes.forEach { it.isEnabled = true }
}

private fun getSelectedBuildType(): CanvasConfig.BuildType {
Expand Down
Loading

0 comments on commit 9153874

Please sign in to comment.