mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-19 16:40:38 -09:00
GP-5536 - Version Tracking - Fixed issue with incorrect plugins being loaded from saved tool
This commit is contained in:
@@ -143,11 +143,22 @@ public class VTPlugin extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
|
||||||
|
removeUnwantedPlugins();
|
||||||
|
|
||||||
addCustomPlugins();
|
addCustomPlugins();
|
||||||
|
|
||||||
maybeShowHelp();
|
maybeShowHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeUnwantedPlugins() {
|
||||||
|
|
||||||
|
List<Plugin> allPlugins = tool.getManagedPlugins();
|
||||||
|
List<Plugin> toRemove = new ArrayList<>(allPlugins);
|
||||||
|
toRemove.remove(this);
|
||||||
|
tool.removePlugins(toRemove);
|
||||||
|
}
|
||||||
|
|
||||||
private void addCustomPlugins() {
|
private void addCustomPlugins() {
|
||||||
|
|
||||||
List<String> names =
|
List<String> names =
|
||||||
|
|||||||
@@ -144,14 +144,20 @@ public class AddToSessionData {
|
|||||||
public void setCorrelators(List<VTProgramCorrelatorFactory> correlators) {
|
public void setCorrelators(List<VTProgramCorrelatorFactory> correlators) {
|
||||||
if (!correlators.equals(this.correlators)) {
|
if (!correlators.equals(this.correlators)) {
|
||||||
this.correlators = correlators;
|
this.correlators = correlators;
|
||||||
// whenever the set of correlators changes, reset the options to force options panel
|
updateOptionsMap();
|
||||||
// to show
|
|
||||||
optionsMap = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptions(Map<VTProgramCorrelatorFactory, VTOptions> optionsMap) {
|
private void updateOptionsMap() {
|
||||||
this.optionsMap = optionsMap;
|
optionsMap.keySet().retainAll(correlators);
|
||||||
|
for (VTProgramCorrelatorFactory correlator : correlators) {
|
||||||
|
if (!optionsMap.containsKey(correlator)) {
|
||||||
|
VTOptions defaultOptions = correlator.createDefaultOptions();
|
||||||
|
if (defaultOptions != null) {
|
||||||
|
optionsMap.put(correlator, defaultOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<VTProgramCorrelatorFactory, VTOptions> getOptions() {
|
public Map<VTProgramCorrelatorFactory, VTOptions> getOptions() {
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ public class OptionsPanel extends JPanel {
|
|||||||
|
|
||||||
private static final Dimension DEFAULT_PREFERRED_SIZE = new Dimension(650, 350);
|
private static final Dimension DEFAULT_PREFERRED_SIZE = new Dimension(650, 350);
|
||||||
|
|
||||||
|
private Map<VTProgramCorrelatorFactory, VTOptions> optionsMap;
|
||||||
private List<OptionsEditorPanel> optionsEditorPanelList = new ArrayList<>();
|
private List<OptionsEditorPanel> optionsEditorPanelList = new ArrayList<>();
|
||||||
private Callback statusChangedCallback;
|
private Callback statusChangedCallback;
|
||||||
private Map<VTProgramCorrelatorFactory, VTOptions> optionsMap = new HashMap<>();
|
|
||||||
|
|
||||||
private JPanel stagingPanel;
|
private JPanel stagingPanel;
|
||||||
|
|
||||||
@@ -63,25 +63,9 @@ public class OptionsPanel extends JPanel {
|
|||||||
return preferredSize;
|
return preferredSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplicable(List<VTProgramCorrelatorFactory> correlators) {
|
void initialize(List<VTProgramCorrelatorFactory> correlators,
|
||||||
updateOptionsMap(correlators);
|
Map<VTProgramCorrelatorFactory, VTOptions> map) {
|
||||||
return !optionsMap.isEmpty();
|
optionsMap = map;
|
||||||
}
|
|
||||||
|
|
||||||
private void updateOptionsMap(List<VTProgramCorrelatorFactory> correlators) {
|
|
||||||
optionsMap.keySet().retainAll(correlators);
|
|
||||||
for (VTProgramCorrelatorFactory correlator : correlators) {
|
|
||||||
if (!optionsMap.containsKey(correlator)) {
|
|
||||||
VTOptions defaultOptions = correlator.createDefaultOptions();
|
|
||||||
if (defaultOptions != null) {
|
|
||||||
optionsMap.put(correlator, defaultOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void initialize(List<VTProgramCorrelatorFactory> correlators) {
|
|
||||||
updateOptionsMap(correlators);
|
|
||||||
JPanel panel = new JPanel(new VerticalLayout(30));
|
JPanel panel = new JPanel(new VerticalLayout(30));
|
||||||
optionsEditorPanelList.clear();
|
optionsEditorPanelList.clear();
|
||||||
for (VTProgramCorrelatorFactory correlator : correlators) {
|
for (VTProgramCorrelatorFactory correlator : correlators) {
|
||||||
@@ -134,8 +118,4 @@ public class OptionsPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<VTProgramCorrelatorFactory, VTOptions> getOptionsMap() {
|
|
||||||
return optionsMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.feature.vt.gui.wizard.add;
|
package ghidra.feature.vt.gui.wizard.add;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import docking.wizard.WizardModel;
|
import docking.wizard.WizardModel;
|
||||||
import docking.wizard.WizardStep;
|
import docking.wizard.WizardStep;
|
||||||
|
import ghidra.feature.vt.api.main.VTProgramCorrelatorFactory;
|
||||||
|
import ghidra.feature.vt.api.util.VTOptions;
|
||||||
import ghidra.util.HelpLocation;
|
import ghidra.util.HelpLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,14 +41,13 @@ public class OptionsStep extends WizardStep<AddToSessionData> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(AddToSessionData data) {
|
public void initialize(AddToSessionData data) {
|
||||||
panel.initialize(data.getCorrelators());
|
panel.initialize(data.getCorrelators(), data.getOptions());
|
||||||
// set the options here so that we know this step was visited
|
|
||||||
data.setOptions(panel.getOptionsMap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isApplicable(AddToSessionData data) {
|
public boolean isApplicable(AddToSessionData data) {
|
||||||
return panel.isApplicable(data.getCorrelators());
|
Map<VTProgramCorrelatorFactory, VTOptions> options = data.getOptions();
|
||||||
|
return !options.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,7 +62,7 @@ public class OptionsStep extends WizardStep<AddToSessionData> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populateData(AddToSessionData data) {
|
public void populateData(AddToSessionData data) {
|
||||||
data.setOptions(panel.getOptionsMap());
|
// stub
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user