Analysis Panel - fixed timing issue in analysis task test; fixed

renderer color bug
This commit is contained in:
dragonmacher
2021-01-26 13:14:07 -05:00
parent 59fa5f6d6b
commit c0152fd32d
3 changed files with 53 additions and 22 deletions

View File

@@ -68,6 +68,13 @@
<B>Edit</B><IMG alt="" src="images/arrow.gif"> <B>Tool Options</B> menu and check <B>Edit</B><IMG alt="" src="images/arrow.gif"> <B>Tool Options</B> menu and check
or uncheck <I>Show Analysis Options</I>. When unchecked, the next time Auto Analysis is or uncheck <I>Show Analysis Options</I>. When unchecked, the next time Auto Analysis is
chosen, the options dialog is skipped, and analysis begins immediately.</P> chosen, the options dialog is skipped, and analysis begins immediately.</P>
<P><IMG alt="" src="images/tip.png"> Any analyzer that is not in its default enablement
state will show a yellowish color in the table of analyzer names.</P>
</BLOCKQUOTE> </BLOCKQUOTE>
</BLOCKQUOTE> </BLOCKQUOTE>

View File

@@ -35,8 +35,9 @@ import ghidra.util.table.column.GColumnRenderer;
*/ */
public class AnalysisEnablementTableModel public class AnalysisEnablementTableModel
extends GDynamicColumnTableModel<AnalyzerEnablementState, Object> { extends GDynamicColumnTableModel<AnalyzerEnablementState, Object> {
private static Color ALT_SELECTED_COLOR = Color.BLUE.brighter();
private static Color ALT_NON_SELECTED__COLOR = new Color(255, 255, 175); private static Color BG_COLOR_NOT_DEFAULT_ENABLEMENT = new Color(255, 255, 200);
private static Color BG_COLOR_NOT_DEFAULT_ENABLEMENT_SELECTED = new Color(177, 212, 236);
private List<AnalyzerEnablementState> analyzerStates; private List<AnalyzerEnablementState> analyzerStates;
private AnalysisPanel panel; private AnalysisPanel panel;
@@ -100,6 +101,16 @@ public class AnalysisEnablementTableModel
return false; return false;
} }
private void setToolTip(Component c, String text) {
if (c instanceof JComponent) {
((JComponent) c).setToolTipText(text);
}
}
//==================================================================================================
// Inner Classes
//==================================================================================================
private class AnalyzerEnabledColumn private class AnalyzerEnabledColumn
extends AbstractDynamicTableColumn<AnalyzerEnablementState, Boolean, Object> { extends AbstractDynamicTableColumn<AnalyzerEnablementState, Boolean, Object> {
EnabledColumnTableCellRenderer renderer = new EnabledColumnTableCellRenderer(); EnabledColumnTableCellRenderer renderer = new EnabledColumnTableCellRenderer();
@@ -155,12 +166,22 @@ public class AnalysisEnablementTableModel
Component component = booleanRenderer.getTableCellRendererComponent(table, value, Component component = booleanRenderer.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column); isSelected, hasFocus, row, column);
if (!getRowObject(row).isDefaultEnablement()) { AnalyzerEnablementState state = getRowObject(row);
component.setBackground(isSelected ? ALT_SELECTED_COLOR : ALT_NON_SELECTED__COLOR); if (state.isDefaultEnablement()) {
if (component instanceof JComponent) { setToolTip(component, null);
((JComponent) component).setToolTipText("This option differs from the default"); return component;
}
} }
// not the default enablement
if (isSelected) {
component.setBackground(BG_COLOR_NOT_DEFAULT_ENABLEMENT_SELECTED);
}
else {
component.setBackground(BG_COLOR_NOT_DEFAULT_ENABLEMENT);
}
setToolTip(component, "This option differs from the default");
return component; return component;
} }
@@ -168,7 +189,6 @@ public class AnalysisEnablementTableModel
public String getFilterString(Boolean t, Settings settings) { public String getFilterString(Boolean t, Settings settings) {
return ""; return "";
} }
} }
private class AnalyzerNameTableCellRenderer extends AbstractGColumnRenderer<String> { private class AnalyzerNameTableCellRenderer extends AbstractGColumnRenderer<String> {
@@ -188,14 +208,23 @@ public class AnalysisEnablementTableModel
component.setForeground( component.setForeground(
ColorUtils.deriveForeground(component.getBackground(), ColorUtils.HUE_RED)); ColorUtils.deriveForeground(component.getBackground(), ColorUtils.HUE_RED));
} }
if (!((AnalyzerEnablementState) data.getRowObject()).isDefaultEnablement()) {
component.setBackground( AnalyzerEnablementState state = (AnalyzerEnablementState) data.getRowObject();
data.isSelected() ? ALT_SELECTED_COLOR : ALT_NON_SELECTED__COLOR); if (state.isDefaultEnablement()) {
if (component instanceof JComponent) { setToolTip(component, null);
((JComponent) component).setToolTipText("This option differs from the default"); return component;
}
} }
// not the default enablement
if (data.isSelected()) {
component.setBackground(BG_COLOR_NOT_DEFAULT_ENABLEMENT_SELECTED);
component.setForeground(Color.BLACK);
}
else {
component.setBackground(BG_COLOR_NOT_DEFAULT_ENABLEMENT);
}
setToolTip(component, "This option differs from the default");
return component; return component;
} }

View File

@@ -296,8 +296,8 @@ public class AnalyzeAllOpenProgramsTaskTest extends AbstractGhidraHeadedIntegrat
AnalysisOptionsDialog optionsDialog = waitForDialogComponent(AnalysisOptionsDialog.class); AnalysisOptionsDialog optionsDialog = waitForDialogComponent(AnalysisOptionsDialog.class);
AnalysisPanel panel = AnalysisPanel panel =
findComponent(optionsDialog.getComponent(), AnalysisPanel.class, false); findComponent(optionsDialog.getComponent(), AnalysisPanel.class, false);
invokeInstanceMethod("deselectAll", panel);
waitForSwing(); runSwing(() -> invokeInstanceMethod("deselectAll", panel));
close(optionsDialog); close(optionsDialog);
} }
@@ -371,12 +371,7 @@ public class AnalyzeAllOpenProgramsTaskTest extends AbstractGhidraHeadedIntegrat
} }
final int analyzerRow = row; final int analyzerRow = row;
runSwing(new Runnable() { runSwing(() -> model.setValueAt(Boolean.TRUE, analyzerRow, 0));
@Override
public void run() {
model.setValueAt(Boolean.TRUE, analyzerRow, 0);
}
});
} }
private void runTask(final AnalyzeAllOpenProgramsTask task) { private void runTask(final AnalyzeAllOpenProgramsTask task) {