GP-3547 Disable Default Settings when they are immutable such as Dynamic

datatype component types.
This commit is contained in:
ghidra1 2025-05-29 10:41:21 -04:00
parent b276bc6b33
commit f9435194a1
9 changed files with 88 additions and 55 deletions

View file

@ -460,6 +460,11 @@ class DataTypeComponentDB implements InternalDataTypeComponent {
dataMgr.dataTypeChanged(getParent(), false);
}
@Override
public boolean isImmutableSettings() {
return false; // NOTE: We could check to see if any editable Settings are defined
}
@Override
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
if (settingsDefinition instanceof TypeDefSettingsDefinition) {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -77,6 +77,11 @@ class DataTypeSettingsDB implements Settings {
return wasLocked;
}
@Override
public boolean isImmutableSettings() {
return locked;
}
@Override
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
if (locked) {
@ -137,9 +142,8 @@ class DataTypeSettingsDB implements Settings {
if (name == null) {
nameStr = "s";
}
Msg.warn(SettingsImpl.class,
"Ignored invalid attempt to modify immutable " + typeStr + "component setting" +
nameStr);
Msg.warn(SettingsImpl.class, "Ignored invalid attempt to modify immutable " + typeStr +
"component setting" + nameStr);
return false;
}
return true;

View file

@ -46,6 +46,11 @@ public interface Data extends CodeUnit, Settings {
*/
public Class<?> getValueClass();
@Override
default boolean isImmutableSettings() {
return true; // NOTE: We could check to see if any editable Settings are defined
}
/**
* Returns true if this data corresponds to string data. This is determined
* by the corresponding data type producing a String value.

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -35,6 +35,11 @@ public class SettingsBuilder implements Settings {
// nada
}
@Override
public boolean isImmutableSettings() {
return false;
}
@Override
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
return settings.isChangeAllowed(settingsDefinition);