Merge remote-tracking branch 'origin/GP-773_ghidravore_graph_visualization_options--SQUASHED'

This commit is contained in:
Ryan Kurtz 2021-08-09 14:13:19 -04:00
commit 69e8119211
84 changed files with 4102 additions and 1822 deletions

View file

@ -17,9 +17,11 @@ package docking.options.editor;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.Border;
import docking.help.Help;
@ -27,7 +29,6 @@ import docking.help.HelpService;
import ghidra.framework.options.*;
import ghidra.util.HelpLocation;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.layout.VerticalLayout;
/**
@ -35,7 +36,7 @@ import ghidra.util.layout.VerticalLayout;
* Panel that shows each property in an Options category or a Group in an
* Options category.
*/
public class OptionsEditorPanel extends JPanel implements OptionsEditor {
public class OptionsEditorPanel extends JPanel {
private EditorStateFactory editorStateFactory;
private Options options;
@ -63,12 +64,9 @@ public class OptionsEditorPanel extends JPanel implements OptionsEditor {
this.optionNames = optionNames;
this.title = title;
Collections.sort(optionNames);
create();
}
@Override
public void dispose() {
propertyChangeListener = null;
editorInfoList.clear();
@ -116,33 +114,11 @@ public class OptionsEditorPanel extends JPanel implements OptionsEditor {
setBorder(border);
}
//==================================================================================================
// OptionsEditor Interface Methods
//==================================================================================================
@Override
public void apply() throws InvalidInputException {
public void apply() {
for (EditorState state : editorInfoList) {
state.applyValue();
}
}
@Override
public void cancel() {
// nothing to do
}
@Override
public void reload() {
// nothing to do, as this component is reloaded when options are changed
}
@Override
public JComponent getEditorComponent(Options o, EditorStateFactory factory) {
return this;
}
@Override
public void setOptionsPropertyChangeListener(PropertyChangeListener listener) {
this.propertyChangeListener = listener;
}

View file

@ -339,13 +339,13 @@ public class OptionsPanel extends JPanel {
if (options == null) {
return null;
}
List<String> optionList = node.getOptionNames();
editor = options.getOptionsEditor();
if (editor == null) {
List<String> optionList = node.getOptionNames();
Collections.sort(optionList);
if (optionList.size() > 0) {
editor = new ScrollableOptionsEditor(options.getName(), options, optionList,
editorStateFactory);
editor = new ScrollableOptionsEditor(options.getName(), optionList);
}
}

View file

@ -29,30 +29,36 @@ import ghidra.util.layout.MiddleLayout;
/**
* Panel that shows each property in an Options category or a Group in an Options category
*/
public class ScrollableOptionsEditor extends JScrollPane implements OptionsEditor {
public class ScrollableOptionsEditor implements OptionsEditor {
private OptionsEditorPanel optionsPanel;
private String title;
private List<String> optionNames;
private JScrollPane scrollPane;
private PropertyChangeListener listener;
/**
* Creates a panel for editing the given options
* Creates a panel for editing options. This version of the constructor allows the client
* to specify the option names to put them in some order other than the default alphabetical
* ordering.
*
* @param title The title of the options panel
* @param options the options for this panel
* @param optionNames the names of the options for this panel
* @param editorStateFactory the factory needed by the editor
*/
public ScrollableOptionsEditor(String title, Options options, List<String> optionNames,
EditorStateFactory editorStateFactory) {
public ScrollableOptionsEditor(String title, List<String> optionNames) {
this.title = title;
this.optionNames = optionNames;
optionsPanel = new OptionsEditorPanel(title, options, optionNames, editorStateFactory);
}
setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED);
setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
// the outer panel is 'Scrollable' and uses a layout that centers the options panel
JPanel outerPanel = new ScollableOptionsPanel();
outerPanel.add(optionsPanel);
setViewportView(outerPanel);
/**
* Creates a panel for editing options. This version of the constructor will get the
* options names from the options object when
* {@link #getEditorComponent(Options, EditorStateFactory)} is called.
* @param title the title for the panel
*/
public ScrollableOptionsEditor(String title) {
this(title, null);
}
//==================================================================================================
@ -61,7 +67,9 @@ public class ScrollableOptionsEditor extends JScrollPane implements OptionsEdito
@Override
public void dispose() {
// stub
if (optionsPanel != null) {
optionsPanel.dispose();
}
}
@Override
@ -81,12 +89,27 @@ public class ScrollableOptionsEditor extends JScrollPane implements OptionsEdito
@Override
public JComponent getEditorComponent(Options options, EditorStateFactory factory) {
return this;
scrollPane = new JScrollPane();
optionsPanel = new OptionsEditorPanel(title, options, optionNames, factory);
optionsPanel.setOptionsPropertyChangeListener(listener);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
// the outer panel is 'Scrollable' and uses a layout that centers the options panel
JPanel outerPanel = new ScollableOptionsPanel();
outerPanel.add(optionsPanel);
scrollPane.setViewportView(outerPanel);
return scrollPane;
}
@Override
public void setOptionsPropertyChangeListener(PropertyChangeListener listener) {
optionsPanel.setOptionsPropertyChangeListener(listener);
this.listener = listener;
if (optionsPanel != null) {
optionsPanel.setOptionsPropertyChangeListener(listener);
}
}
//==================================================================================================
@ -120,7 +143,7 @@ public class ScrollableOptionsEditor extends JScrollPane implements OptionsEdito
// scrollbars.
//
Dimension mySize = getPreferredSize();
Dimension viewSize = ScrollableOptionsEditor.this.getViewport().getSize();
Dimension viewSize = scrollPane.getViewport().getSize();
boolean viewIsLarger = viewSize.height > mySize.height;
return viewIsLarger;
}
@ -135,7 +158,7 @@ public class ScrollableOptionsEditor extends JScrollPane implements OptionsEdito
// scrollbars.
//
Dimension mySize = getPreferredSize();
Dimension viewSize = ScrollableOptionsEditor.this.getViewport().getSize();
Dimension viewSize = scrollPane.getViewport().getSize();
boolean viewIsLarger = viewSize.width > mySize.width;
return viewIsLarger;
}
@ -147,4 +170,8 @@ public class ScrollableOptionsEditor extends JScrollPane implements OptionsEdito
}
}
// for testing
public JComponent getComponent() {
return scrollPane;
}
}