Initial AppCode UI Designer

This commit is contained in:
Alexander Lobas
2012-07-03 13:38:54 +04:00
parent 034b4e138c
commit b21232591a
4 changed files with 52 additions and 35 deletions
@@ -40,7 +40,9 @@ public class AndroidDesignerBundle {
private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) bundle = ourBundle.get();
if (ourBundle != null) {
bundle = ourBundle.get();
}
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<ResourceBundle>(bundle);
@@ -40,7 +40,9 @@ public class DesignerBundle {
private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) bundle = ourBundle.get();
if (ourBundle != null) {
bundle = ourBundle.get();
}
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<ResourceBundle>(bundle);
@@ -45,7 +45,7 @@ public abstract class MetaManager {
private static final String TAG = "tag";
private static final String WRAP_IN = "wrap-in";
private static final Logger LOG = Logger.getInstance("#com.intellij.designer.model.MetaManager");
protected static final Logger LOG = Logger.getInstance("#com.intellij.designer.model.MetaManager");
private final Map<String, MetaModel> myTag2Model = new HashMap<String, MetaModel>();
private final Map<String, MetaModel> myTarget2Model = new HashMap<String, MetaModel>();
@@ -111,7 +111,7 @@ public abstract class MetaManager {
String target = element.getAttributeValue("class");
String tag = element.getAttributeValue(TAG);
MetaModel meta = new MetaModel(model, target, tag);
MetaModel meta = createModel(model, target, tag);
String layout = element.getAttributeValue("layout");
if (layout != null) {
@@ -144,35 +144,7 @@ public abstract class MetaManager {
Element properties = element.getChild("properties");
if (properties != null) {
Attribute inplace = properties.getAttribute("inplace");
if (inplace != null) {
meta.setInplaceProperties(StringUtil.split(inplace.getValue(), " "));
}
Attribute top = properties.getAttribute("top");
if (top != null) {
meta.setTopProperties(StringUtil.split(top.getValue(), " "));
}
Attribute normal = properties.getAttribute("normal");
if (normal != null) {
meta.setNormalProperties(StringUtil.split(normal.getValue(), " "));
}
Attribute important = properties.getAttribute("important");
if (important != null) {
meta.setImportantProperties(StringUtil.split(important.getValue(), " "));
}
Attribute expert = properties.getAttribute("expert");
if (expert != null) {
meta.setExpertProperties(StringUtil.split(expert.getValue(), " "));
}
Attribute deprecated = properties.getAttribute("deprecated");
if (deprecated != null) {
meta.setDeprecatedProperties(StringUtil.split(deprecated.getValue(), " "));
}
loadProperties(meta, properties);
}
Element morphing = element.getChild("morphing");
@@ -180,6 +152,8 @@ public abstract class MetaManager {
modelToMorphing.put(meta, StringUtil.split(morphing.getAttribute("to").getValue(), " "));
}
loadOther(meta, element);
if (tag != null) {
myTag2Model.put(tag, meta);
}
@@ -189,6 +163,45 @@ public abstract class MetaManager {
}
}
protected MetaModel createModel(Class<RadComponent> model, String target, String tag) throws Exception {
return new MetaModel(model, target, tag);
}
protected void loadProperties(MetaModel meta, Element properties) throws Exception {
Attribute inplace = properties.getAttribute("inplace");
if (inplace != null) {
meta.setInplaceProperties(StringUtil.split(inplace.getValue(), " "));
}
Attribute top = properties.getAttribute("top");
if (top != null) {
meta.setTopProperties(StringUtil.split(top.getValue(), " "));
}
Attribute normal = properties.getAttribute("normal");
if (normal != null) {
meta.setNormalProperties(StringUtil.split(normal.getValue(), " "));
}
Attribute important = properties.getAttribute("important");
if (important != null) {
meta.setImportantProperties(StringUtil.split(important.getValue(), " "));
}
Attribute expert = properties.getAttribute("expert");
if (expert != null) {
meta.setExpertProperties(StringUtil.split(expert.getValue(), " "));
}
Attribute deprecated = properties.getAttribute("deprecated");
if (deprecated != null) {
meta.setDeprecatedProperties(StringUtil.split(deprecated.getValue(), " "));
}
}
protected void loadOther(MetaModel meta, Element element) throws Exception {
}
private void loadGroup(Element element) throws Exception {
PaletteGroup group = new PaletteGroup(element.getAttributeValue(NAME));
@@ -35,8 +35,8 @@ public class MetaModel {
private final String myTag;
private DefaultPaletteItem myPaletteItem;
private String myTitle;
private String myIconPath;
private Icon myIcon;
protected String myIconPath;
protected Icon myIcon;
private String myCreation;
private boolean myDelete = true;
private List<String> myInplaceProperties = Collections.emptyList();