Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Extra option lost for custom rendering style" #21630

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,21 @@ public class RenderingRuleStorageProperties {

final Map<String, RenderingRuleProperty> properties;
// C++
final List<RenderingRuleProperty> rules ;
final List<RenderingRuleProperty> customRules ;
final List<RenderingRuleProperty> rules;
final Map<String, RenderingRuleProperty> customRules;


public RenderingRuleStorageProperties() {
properties = new LinkedHashMap<String, RenderingRuleProperty>();
rules = new ArrayList<RenderingRuleProperty>();
customRules = new ArrayList<RenderingRuleProperty>();
properties = new LinkedHashMap<>();
rules = new ArrayList<>();
customRules = new LinkedHashMap<>();
createDefaultRenderingRuleProperties();
}

public RenderingRuleStorageProperties(RenderingRuleStorageProperties toClone) {
properties = new LinkedHashMap<String, RenderingRuleProperty>(toClone.properties);
rules = new ArrayList<RenderingRuleProperty>(toClone.rules);
customRules = new ArrayList<RenderingRuleProperty>(toClone.customRules);
properties = new LinkedHashMap<>(toClone.properties);
rules = new ArrayList<>(toClone.rules);
customRules = new LinkedHashMap<>(toClone.customRules);
createDefaultRenderingRuleProperties();
}

Expand Down Expand Up @@ -329,37 +329,40 @@ public RenderingRuleProperty[] getPoperties() {
}

public List<RenderingRuleProperty> getCustomRules() {
return customRules;
return new ArrayList<>(customRules.values());
}

public RenderingRuleProperty getCustomRule(String attrName) {
for (RenderingRuleProperty p : customRules) {
if (p.getAttrName().equals(attrName)) {
return p;
}
}
return null;
return customRules.get(attrName);
}

private RenderingRuleProperty registerRuleInternal(RenderingRuleProperty p) {
RenderingRuleProperty existing = get(p.getAttrName());
properties.put(p.getAttrName(), p);
if(existing == null) {
return registerRuleInternal(p, true);
}

private RenderingRuleProperty registerRuleInternal(RenderingRuleProperty p, boolean overwriteExisting) {
String attrName = p.getAttrName();
RenderingRuleProperty existing = get(attrName);
if (existing == null) {
properties.put(attrName, p);
p.setId(rules.size());
rules.add(p);
} else if (overwriteExisting) {
int id = existing.getId();
p.setId(id);
rules.set(id, p);
properties.put(attrName, p);
customRules.remove(attrName);
} else {
p.setId(existing.getId());
rules.set(existing.getId(), p);
customRules.remove(existing);
p = existing;
}
return p;
}

public RenderingRuleProperty registerRule(RenderingRuleProperty p) {
RenderingRuleProperty ps = registerRuleInternal(p);
if(!customRules.contains(ps)) {
customRules.add(p);
public void registerRule(RenderingRuleProperty p, boolean overwriteExisting) {
registerRuleInternal(p, overwriteExisting);
if (!customRules.containsKey(p.attrName)) {
customRules.put(p.attrName, p);
}
return ps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public void startElement(Map<String, String> attrsMap, String name) throws XmlPu
if (attrsMap.get("possibleValues") != null) {
prop.setPossibleValues(attrsMap.get("possibleValues").split(","));
}
PROPS.registerRule(prop);
PROPS.registerRule(prop, !addon);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear - why we should not overwrite rule in case of addon?

} else if("renderingConstant".equals(name)){ //$NON-NLS-1$
if(!renderingConstants.containsKey(attrsMap.get("name"))){
renderingConstants.put(attrsMap.get("name"), attrsMap.get("value"));
Expand Down
Loading