mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-5536 - Version Tracking - Fixed issue with incorrect plugins being loaded from saved tool
This commit is contained in:
parent
7e3395dc62
commit
f7dc225c38
4 changed files with 34 additions and 34 deletions
|
@ -143,11 +143,22 @@ public class VTPlugin extends Plugin {
|
|||
|
||||
@Override
|
||||
protected void init() {
|
||||
|
||||
removeUnwantedPlugins();
|
||||
|
||||
addCustomPlugins();
|
||||
|
||||
maybeShowHelp();
|
||||
}
|
||||
|
||||
private void removeUnwantedPlugins() {
|
||||
|
||||
List<Plugin> allPlugins = tool.getManagedPlugins();
|
||||
List<Plugin> toRemove = new ArrayList<>(allPlugins);
|
||||
toRemove.remove(this);
|
||||
tool.removePlugins(toRemove);
|
||||
}
|
||||
|
||||
private void addCustomPlugins() {
|
||||
|
||||
List<String> names =
|
||||
|
|
|
@ -144,14 +144,20 @@ public class AddToSessionData {
|
|||
public void setCorrelators(List<VTProgramCorrelatorFactory> correlators) {
|
||||
if (!correlators.equals(this.correlators)) {
|
||||
this.correlators = correlators;
|
||||
// whenever the set of correlators changes, reset the options to force options panel
|
||||
// to show
|
||||
optionsMap = null;
|
||||
updateOptionsMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void setOptions(Map<VTProgramCorrelatorFactory, VTOptions> optionsMap) {
|
||||
this.optionsMap = optionsMap;
|
||||
private void updateOptionsMap() {
|
||||
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() {
|
||||
|
|
|
@ -37,9 +37,9 @@ public class OptionsPanel extends JPanel {
|
|||
|
||||
private static final Dimension DEFAULT_PREFERRED_SIZE = new Dimension(650, 350);
|
||||
|
||||
private Map<VTProgramCorrelatorFactory, VTOptions> optionsMap;
|
||||
private List<OptionsEditorPanel> optionsEditorPanelList = new ArrayList<>();
|
||||
private Callback statusChangedCallback;
|
||||
private Map<VTProgramCorrelatorFactory, VTOptions> optionsMap = new HashMap<>();
|
||||
|
||||
private JPanel stagingPanel;
|
||||
|
||||
|
@ -63,25 +63,9 @@ public class OptionsPanel extends JPanel {
|
|||
return preferredSize;
|
||||
}
|
||||
|
||||
public boolean isApplicable(List<VTProgramCorrelatorFactory> correlators) {
|
||||
updateOptionsMap(correlators);
|
||||
return !optionsMap.isEmpty();
|
||||
}
|
||||
|
||||
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);
|
||||
void initialize(List<VTProgramCorrelatorFactory> correlators,
|
||||
Map<VTProgramCorrelatorFactory, VTOptions> map) {
|
||||
optionsMap = map;
|
||||
JPanel panel = new JPanel(new VerticalLayout(30));
|
||||
optionsEditorPanelList.clear();
|
||||
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;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import docking.wizard.WizardModel;
|
||||
import docking.wizard.WizardStep;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
/**
|
||||
|
@ -37,14 +41,13 @@ public class OptionsStep extends WizardStep<AddToSessionData> {
|
|||
|
||||
@Override
|
||||
public void initialize(AddToSessionData data) {
|
||||
panel.initialize(data.getCorrelators());
|
||||
// set the options here so that we know this step was visited
|
||||
data.setOptions(panel.getOptionsMap());
|
||||
panel.initialize(data.getCorrelators(), data.getOptions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(AddToSessionData data) {
|
||||
return panel.isApplicable(data.getCorrelators());
|
||||
Map<VTProgramCorrelatorFactory, VTOptions> options = data.getOptions();
|
||||
return !options.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +62,7 @@ public class OptionsStep extends WizardStep<AddToSessionData> {
|
|||
|
||||
@Override
|
||||
public void populateData(AddToSessionData data) {
|
||||
data.setOptions(panel.getOptionsMap());
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue