|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.fr.design.mainframe.simple; |
|
|
|
package com.fr.design.mainframe.simple; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
import com.fr.stable.xml.XMLable; |
|
|
|
import com.fr.stable.xml.XMLable; |
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
@ -14,7 +16,7 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class SimpleDesignerConfig implements XMLable { |
|
|
|
public class SimpleDesignerConfig implements XMLable { |
|
|
|
|
|
|
|
|
|
|
|
private static final HashMap<String, SimpleDesignerConfig> configs = new HashMap<>(); |
|
|
|
private static final Map<String, SimpleDesignerConfig> configs = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private SimpleDesignerConfig(String name) { |
|
|
|
private SimpleDesignerConfig(String name) { |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
@ -22,7 +24,7 @@ public class SimpleDesignerConfig implements XMLable { |
|
|
|
|
|
|
|
|
|
|
|
public static SimpleDesignerConfig getInstance(String name) { |
|
|
|
public static SimpleDesignerConfig getInstance(String name) { |
|
|
|
SimpleDesignerConfig config = configs.get(name); |
|
|
|
SimpleDesignerConfig config = configs.get(name); |
|
|
|
if(config == null) { |
|
|
|
if (config == null) { |
|
|
|
config = new SimpleDesignerConfig(name); |
|
|
|
config = new SimpleDesignerConfig(name); |
|
|
|
configs.put(name, config); |
|
|
|
configs.put(name, config); |
|
|
|
} |
|
|
|
} |
|
|
@ -31,42 +33,51 @@ public class SimpleDesignerConfig implements XMLable { |
|
|
|
|
|
|
|
|
|
|
|
private String name = ""; |
|
|
|
private String name = ""; |
|
|
|
|
|
|
|
|
|
|
|
private HashMap<String, String> content = new HashMap<>(); |
|
|
|
private JSONObject content = new JSONObject(); |
|
|
|
|
|
|
|
|
|
|
|
public void addAttr(String key, String value) { |
|
|
|
public void addAttr(String key, String value) { |
|
|
|
content.put(key, value); |
|
|
|
content.put(key, value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Map<String, String> getContent() { |
|
|
|
public JSONObject getContent() { |
|
|
|
return content; |
|
|
|
return content; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setContent(JSONObject content) { |
|
|
|
|
|
|
|
this.content = content; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void readXML(XMLableReader reader) { |
|
|
|
public void readXML(XMLableReader reader) { |
|
|
|
if (reader.isAttr()) { |
|
|
|
if (reader.isAttr()) { |
|
|
|
content.putAll(reader.getAttrs()); |
|
|
|
String rawContent = reader.getAttrAsString("content", null); |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(rawContent)) { |
|
|
|
|
|
|
|
this.content = new JSONObject(rawContent); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void writeXML(XMLPrintWriter writer) { |
|
|
|
public void writeXML(XMLPrintWriter writer) { |
|
|
|
writer.startTAG(name); |
|
|
|
writer.startTAG(name); |
|
|
|
content.forEach(writer::attr); |
|
|
|
if (this.content != null) { |
|
|
|
|
|
|
|
writer.attr("content", this.content.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
writer.end(); |
|
|
|
writer.end(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object clone() throws CloneNotSupportedException { |
|
|
|
public Object clone() throws CloneNotSupportedException { |
|
|
|
SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); |
|
|
|
SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); |
|
|
|
cloned.content = new HashMap<>(content); |
|
|
|
if (this.content != null) { |
|
|
|
|
|
|
|
cloned.content = new JSONObject(this.content.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cloned.name = this.name; |
|
|
|
return cloned; |
|
|
|
return cloned; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getName() { |
|
|
|
public String getName() { |
|
|
|
return name; |
|
|
|
return name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) { |
|
|
|
|
|
|
|
this.name = name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|