UIB : Notify multiple styles when set position and set size. 83/22583/1
authornakyoung2.choi <nakyoung2.choi@samsung.com>
Mon, 9 Jun 2014 04:38:05 +0000 (13:38 +0900)
committernakyoung2.choi <nakyoung2.choi@samsung.com>
Mon, 9 Jun 2014 04:38:05 +0000 (13:38 +0900)
Change-Id: Ib187a3eaaacdf48c60c3f9cf43818b7e968ffdad
Signed-off-by: nakyoung2.choi <nakyoung2.choi@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/Part.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/css/CssEvent.java

index bc71789..88c3fb0 100644 (file)
@@ -24,6 +24,7 @@
 package org.tizen.webuibuilder.model;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -576,14 +577,7 @@ public class Part implements ISerializer {
     public Rectangle getPositionProperty() {
         if (getPositionMode() == PositionMode.ABSOLUTE_POSITION) {
             // return position;
-            Part page = getOwnerPage();
-            String selectorName = EMPTY;
-            if (page == null) {
-                selectorName = SHARP + getIdPropertyValue();
-            } else {
-                selectorName =
-                        SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-            }
+//            String selectorName = getDefaultSelectorName();
 
 //             String left = getSelectorPropertyValue(selectorName, LEFT);
 //             String top = getSelectorPropertyValue(selectorName, TOP);
@@ -603,14 +597,7 @@ public class Part implements ISerializer {
             return rect;
         } else if (getPositionMode() == PositionMode.RELATIVE_POSITION) {
             // return position;
-            Part page = getOwnerPage();
-            String selectorName = EMPTY;
-            if (page == null) {
-                selectorName = SHARP + getIdPropertyValue();
-            } else {
-                selectorName =
-                        SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-            }
+            String selectorName = getDefaultSelectorName();
 
             String left = getSelectorPropertyValue(selectorName, LEFT);
             String top = getSelectorPropertyValue(selectorName, TOP);
@@ -725,14 +712,7 @@ public class Part implements ISerializer {
             lockRefresh();
             //Point newPosition = ScreenToPage(new Point(position.x, position.y));
             Point newPosition = new Point(position.x, position.y);
-            Part page = getOwnerPage();
-            String selectorName = EMPTY;
-            if (page == null) {
-                selectorName = SHARP + getIdPropertyValue();
-            } else {
-                selectorName =
-                        SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-            }
+            String selectorName = getDefaultSelectorName();
 
             // String parentName = TypeDescriptor.ID_OF_GROUP_POSITION;
             setSelectorPropertyValue(selectorName, LEFT, String.valueOf(newPosition.x) + PX, null);
@@ -746,19 +726,14 @@ public class Part implements ISerializer {
             // this.position.setBounds(position);
             // }
             unlockRefresh();
-            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, null, null));
+            
+            List<String> keyList = Arrays.asList(LEFT, TOP, WIDTH, HEIGHT);
+            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, keyList));
             fireEvent(new CssEvent(EventType.CSS_POSITION_CHANGED, this, selectorName, EMPTY, EMPTY));
         } else if (getPositionMode() == PositionMode.RELATIVE_POSITION) {
             lockRefresh();
             // Point newPosition = ScreenToPage(new Point(position.x, position.y));
-            Part page = getOwnerPage();
-            String selectorName = EMPTY;
-            if (page == null) {
-                selectorName = SHARP + getIdPropertyValue();
-            } else {
-                selectorName =
-                        SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-            }
+            String selectorName = getDefaultSelectorName();
 
             // String parentName = TypeDescriptor.ID_OF_GROUP_POSITION;
             // setSelectorPropertyValue(selectorName, LEFT, String.valueOf(newPosition.x) + PX,
@@ -774,7 +749,9 @@ public class Part implements ISerializer {
             // this.position.setBounds(position);
             // }
             unlockRefresh();
-            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, null, null));
+            
+            List<String> keyList = Arrays.asList(WIDTH, HEIGHT);
+            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, keyList));
             fireEvent(new CssEvent(EventType.CSS_POSITION_CHANGED, this, selectorName, EMPTY, EMPTY));
         }
 
@@ -810,19 +787,15 @@ public class Part implements ISerializer {
             // this.position.setBounds(position);
             // }
             unlockRefresh();
-            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, null, null));
+            
+            List<String> keyList = Arrays.asList(LEFT, TOP);
+            
+            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, keyList));
             fireEvent(new CssEvent(EventType.CSS_POSITION_CHANGED, this, selectorName, EMPTY, EMPTY));
         } else if (getPositionMode() == PositionMode.RELATIVE_POSITION) {
             lockRefresh();
             // Point newPosition = ScreenToPage(new Point(position.x, position.y));
-            Part page = getOwnerPage();
-            String selectorName = EMPTY;
-            if (page == null) {
-                selectorName = SHARP + getIdPropertyValue();
-            } else {
-                selectorName =
-                        SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-            }
+            String selectorName = getDefaultSelectorName();
 
             // String parentName = TypeDescriptor.ID_OF_GROUP_POSITION;
             // setSelectorPropertyValue(selectorName, LEFT, String.valueOf(newPosition.x) + PX,
@@ -835,7 +808,7 @@ public class Part implements ISerializer {
             // this.position.setBounds(position);
             // }
             unlockRefresh();
-            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, null, null));
+            fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, null));
             fireEvent(new CssEvent(EventType.CSS_POSITION_CHANGED, this, selectorName, EMPTY, EMPTY));
         }
 
@@ -859,15 +832,7 @@ public class Part implements ISerializer {
         Rectangle newPosition = new Rectangle();
 
         if (getPositionMode() == PositionMode.ABSOLUTE_POSITION) {
-            Part page = getOwnerPage();
-            String selectorName = EMPTY;
-            if (page == null) {
-                selectorName = SHARP + getIdPropertyValue();
-            } else {
-                selectorName =
-                        SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-            }
-
+            String selectorName = getDefaultSelectorName();
             String left = getSelectorPropertyValue(selectorName, LEFT);
             String top = getSelectorPropertyValue(selectorName, TOP);
             String width = getSelectorPropertyValue(selectorName, WIDTH);
@@ -908,19 +873,15 @@ public class Part implements ISerializer {
         // }
 
         lockRefresh();
-        Part page = getOwnerPage();
-        String selectorName = EMPTY;
-        if (page == null) {
-            selectorName = SHARP + getIdPropertyValue();
-        } else {
-            selectorName = SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
-        }
+        String selectorName = getDefaultSelectorName();
 
         // String parentName = TypeDescriptor.ID_OF_GROUP_POSITION;
         setSelectorPropertyValue(selectorName, WIDTH, String.valueOf(size.x) + PX, null);
         setSelectorPropertyValue(selectorName, HEIGHT, String.valueOf(size.y) + PX, null);
         unlockRefresh();
-        fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, null, null));
+        
+        List<String> keyList = Arrays.asList(WIDTH, HEIGHT);
+        fireEvent(new CssEvent(EventType.CSS_NEED_REFRESH, this, selectorName, keyList));
         fireEvent(new CssEvent(EventType.CSS_POSITION_CHANGED, this, selectorName, EMPTY, EMPTY));
 
         fireEvent(new PartEvent(PartEvent.EventType.POSITION_CHANGED, this, EMPTY, EMPTY));
index 0a01fd4..bfb112b 100644 (file)
@@ -23,6 +23,9 @@
 
 package org.tizen.webuibuilder.model.css;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.tizen.webuibuilder.model.Part;
 
 
@@ -67,6 +70,11 @@ public class CssEvent {
      * A parent key.
      */
     private String parentKey;
+    
+    /**
+     * Modified keys.
+     */
+    private List<String> keyList = new ArrayList<String>();
 
     /**
      * Constructor.
@@ -115,6 +123,25 @@ public class CssEvent {
         this.value = value;
         this.parentKey = parentKey;
     }
+    
+    /**
+     * Constructor.
+     * 
+     * @param type
+     *            an event type
+     * @param part
+     *            a {@link Part}
+     * @param selectorName
+     *            a selector name
+     * @param keyList
+     *            modified keys
+     */
+    public CssEvent(EventType type, Part part, String selectorName, List<String> keyList) {
+        this.type = type;
+        this.part = part;
+        this.selectorName = selectorName;
+        this.keyList = keyList;
+    }
 
     /**
      * Gets an event type.
@@ -169,5 +196,14 @@ public class CssEvent {
     public Part getPart() {
         return part;
     }
+    
+    /**
+     * Gets modified key list.
+     * 
+     * @return key list
+     */
+    public List<String> getKeyList() {
+        return keyList;
+    }
 
 }