DATABIND : Fixed a bug that can not refresh in the binding info panel. 00/19500/2
authorjaeyeol lee <jaeyeol148.lee@samsung.com>
Mon, 14 Apr 2014 05:14:19 +0000 (14:14 +0900)
committerjaeyeol lee <jaeyeol148.lee@samsung.com>
Mon, 14 Apr 2014 05:26:00 +0000 (14:26 +0900)
Add a listener to the page

Change-Id: Icc511f3153a937d6465838afba15a15090a48792
Signed-off-by: jaeyeol lee <jaeyeol148.lee@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/DataBindingEventDelegater.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/DataBindingPage.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/model/BindingDataSet.java

index 67742fa..8405d15 100644 (file)
@@ -3,11 +3,11 @@ package org.tizen.webuibuilder.ui.views.databinding;
 import org.eclipse.gef.commands.CommandStack;
 import org.tizen.webuibuilder.BuilderConstants;
 import org.tizen.webuibuilder.gef.commands.SetPartPropertyCommand;
-import org.tizen.webuibuilder.model.IPartListener;
 import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.PartEvent;
+import org.tizen.webuibuilder.model.page.IPageDataListener;
+import org.tizen.webuibuilder.model.page.PageDataEvent;
 
-public class DataBindingEventDelegater implements IPartListener {
+public class DataBindingEventDelegater implements IPageDataListener {
        
        private CommandStack commandStack;
        private DataBindingPage dataBindingPage;
@@ -17,39 +17,19 @@ public class DataBindingEventDelegater implements IPartListener {
                this.commandStack = commandStack;
                this.dataBindingPage = dataBindingPage;
        }
-
-       @Override
-       public void childAdded(PartEvent event) {       
-       }
-
+       
        @Override
-       public void childMoved(PartEvent event) {
+       public void pagePreDelete(PageDataEvent e) {
        }
 
        @Override
-       public void childRemoved(PartEvent event) {
+       public void pageRenamed(PageDataEvent e) {
        }
 
        @Override
-       public void propertyChanged(PartEvent event) {
+       public void pageChanged(PageDataEvent e) {
                dataBindingPage.refresh();
        }
-
-       @Override
-       public void positionChanged(PartEvent event) {
-       }
-
-       @Override
-       public void eventChanged(PartEvent event) {
-       }
-
-       @Override
-       public void visualPositionChanged(PartEvent event) {
-       }
-
-       @Override
-       public void needRefresh(PartEvent event) {
-       }
        
        public void valueChanged(Part part, String attributeDataBind,
                        String value, boolean undoable) {
index 21e1692..aae6f4b 100644 (file)
@@ -126,7 +126,7 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
     private RemoveBindingInfoAction removeBindingInfoAction;
     private PageDesigner pageDesigner = null;
     private DataBindingEventDelegater delegater;
-    private Part oldSelectedModel = null;
+    private List<Part> pageList = new ArrayList<Part>();
     private IAction undoHandler;
     private IAction redoHandler;
     //private List<String> itemPath;
@@ -136,16 +136,17 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
     }
     
     private void addListeners(Part model) {
-       if (model != null) {
-               model.addPartListener(delegater);
+       if (pageDesigner != null) {
+               PageData pageData = pageDesigner.getAppManager().getPageData(model.getPropertyValue("id"));
+               pageData.addPageListener(delegater);
        }
     }
     
     private void removeListeners(Part model) {
-        if (model != null) {
-            // TODO : support multi selection
-            model.removePartListener(delegater);
-        }
+       if (pageDesigner != null) {
+               PageData pageData = pageDesigner.getAppManager().getPageData(model.getPropertyValue("id"));
+               pageData.removePageListener(delegater);
+       }
     }
 
     /**
@@ -316,7 +317,7 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
             for (PageData pageData : pages) {
                 List<Part> parts = pageData.getPagePart().getChildren();
                 // parts.get(0).getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND);
-                refreshBindingInfo(parts);
+                refreshBindingInfo(parts); 
             }
         }
     }
@@ -870,7 +871,14 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
     
     @Override
     public void dispose() {
-        pageDesigner.getAppManager().getBindingDataSet().removePageListener(this);
+       if (pageDesigner != null) {
+               pageDesigner.getAppManager().getBindingDataSet().removeBindingDataListener(this);
+       }
+       
+        for (Part pagePart : pageList) {
+               removeListeners(pagePart);
+        }
+        pageList.clear();
         super.dispose();
     }
 
@@ -924,7 +932,6 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
                }
         });
         
-        
         makeBindingInfoContextMenu();
     }
     
@@ -1326,7 +1333,6 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
         return this.pageDesigner;
     }
 
-       
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
                if (selection instanceof StructuredSelection && !selection.isEmpty()) {
             StructuredSelection ssel = (StructuredSelection) selection;
@@ -1347,13 +1353,12 @@ public class DataBindingPage extends Page implements IBindingDataSetListener {
                     }
                 }
                 
-                
-                               if ((oldSelectedModel == null) || (!oldSelectedModel.equals(selModels.get(0)))) {
-                                       removeListeners(oldSelectedModel);
-                       addListeners(selModels.get(0));
-                       oldSelectedModel = selModels.get(0);
-                               } 
-                
+                if (selModels.get(0).getOwnerPage() != null) {
+                       if (!pageList.contains(selModels.get(0).getOwnerPage())) {
+                               pageList.add(selModels.get(0).getOwnerPage());
+                       addListeners(selModels.get(0).getOwnerPage());
+                       }
+                }
             }
         }
        }
index fe2e27b..50e3e00 100644 (file)
@@ -382,14 +382,6 @@ public class BindingDataSet {
         return getDataSources().size();
     }
     
-    public void removePageListener(IBindingDataSetListener listener) {
-        if (!processEventFlag) {
-            listeners.remove(listener);
-        } else {
-            removeListeners.add(listener);
-        }
-    }
-    
     private void fireEvent(final BindingDataSetEvent bindingDataEvent) {
         Display.getDefault().syncExec(new Runnable() {
             @Override