mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch 'origin/GP-3547_ghidra1_DefaultSettingsFix'
This commit is contained in:
commit
48b8bc0fcc
9 changed files with 88 additions and 55 deletions
|
@ -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.
|
||||
|
@ -21,9 +21,14 @@ package ghidra.docking.settings;
|
|||
* of value and how to interpret the value is done by the SettingsDefinition object.
|
||||
*/
|
||||
public interface Settings {
|
||||
|
||||
|
||||
static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
/**
|
||||
* {@return true if settings may not be modified}
|
||||
*/
|
||||
boolean isImmutableSettings();
|
||||
|
||||
/**
|
||||
* Determine if a settings change corresponding to the specified
|
||||
* settingsDefinition is permitted.
|
||||
|
@ -54,14 +59,14 @@ public interface Settings {
|
|||
* @return the String value for a key
|
||||
*/
|
||||
String getString(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the object associated with the given name
|
||||
* @param name the key used to retrieve a value
|
||||
* @return the object associated with a given key
|
||||
*/
|
||||
Object getValue(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Associates the given long value with the name.
|
||||
* Note that an attempted setting change may be ignored if prohibited
|
||||
|
@ -79,7 +84,7 @@ public interface Settings {
|
|||
* @param value the value associated with the key
|
||||
*/
|
||||
void setString(String name, String value);
|
||||
|
||||
|
||||
/**
|
||||
* Associates the given object with the name.
|
||||
* Note that an attempted setting change may be ignored if prohibited
|
||||
|
@ -88,24 +93,24 @@ public interface Settings {
|
|||
* @param value the value to associate with the key
|
||||
*/
|
||||
void setValue(String name, Object value);
|
||||
|
||||
|
||||
/**
|
||||
* Removes any value associated with the given name
|
||||
* @param name the key to remove any association
|
||||
*/
|
||||
void clearSetting(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Removes all name-value pairs from this settings object
|
||||
*/
|
||||
void clearAllSettings();
|
||||
|
||||
|
||||
/**
|
||||
* Get this list of keys that currently have values associated with them
|
||||
* @return an array of string keys.
|
||||
*/
|
||||
String[] getNames();
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if there are no key-value pairs stored in this settings object.
|
||||
* This is not a reflection of the underlying default settings which may still
|
||||
|
@ -113,7 +118,7 @@ public interface Settings {
|
|||
* @return true if there are no key-value pairs stored in this settings object
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the underlying default settings for these settings or null if there are none
|
||||
* @return underlying default settings or null
|
||||
|
|
|
@ -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.
|
||||
|
@ -72,8 +72,8 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
this();
|
||||
if (settings != null) {
|
||||
String[] names = settings.getNames();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
map.put(names[i], settings.getValue(names[i]));
|
||||
for (String name : names) {
|
||||
map.put(name, settings.getValue(name));
|
||||
}
|
||||
defaultSettings = settings.getDefaultSettings();
|
||||
}
|
||||
|
@ -100,6 +100,11 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
this.changeSourceObj = changeSourceObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImmutableSettings() {
|
||||
return immutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChangeAllowed(SettingsDefinition settingsDefinition) {
|
||||
if (immutable) {
|
||||
|
@ -147,9 +152,8 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
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;
|
||||
|
@ -212,10 +216,9 @@ public class SettingsImpl implements Settings, Serializable {
|
|||
@Override
|
||||
public String[] getNames() {
|
||||
String[] names = new String[map.size()];
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
names[i++] = it.next();
|
||||
for (String element : map.keySet()) {
|
||||
names[i++] = element;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue