DATABIND : Change the Data Source Dialog Return Type. 75/18775/1
authorparary <kyunghan80.park@samsung.com>
Tue, 1 Apr 2014 03:34:27 +0000 (12:34 +0900)
committerparary <kyunghan80.park@samsung.com>
Tue, 1 Apr 2014 03:34:27 +0000 (12:34 +0900)
Change-Id: Ic5ccc22e7a286e680519d3dc186f7cc5681ee5d5
Signed-off-by: parary <kyunghan80.park@samsung.com>
org.tizen.webuibuilder/.gitignore [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/actions/EditDataSourceAction.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/dialog/SetSourcePage.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/dialog/StaticSubPage.java

diff --git a/org.tizen.webuibuilder/.gitignore b/org.tizen.webuibuilder/.gitignore
new file mode 100644 (file)
index 0000000..63371cb
--- /dev/null
@@ -0,0 +1,22 @@
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
+/bin
index c5105e7..6fd4dd5 100644 (file)
@@ -115,12 +115,12 @@ public class EditDataSourceAction extends SelectionAction {
 
         
         //TODO remove treeItem
-        SetSourceDialog dlg =
-                new SetSourceDialog(Display.getCurrent().getActiveShell(), view, treeItem);
-        BindingData dataSource = dlg.open();
+//        SetSourceDialog dlg =
+//                new SetSourceDialog(Display.getCurrent().getActiveShell(), view, treeItem);
+//        BindingData dataSource = dlg.open();
 
-//        SetSourcePage dlg = new SetSourcePage(Display.getCurrent().getActiveShell(), view, treeItem);
-//        String message = dlg.open();
+        SetSourcePage dlg = new SetSourcePage(Display.getCurrent().getActiveShell(), treeItem);
+        BindingData dataSource = dlg.open();
 
         if (dataSource != null) {
             IPage page = view.getCurrentPage();
index 250f1f7..f1972d5 100644 (file)
@@ -62,15 +62,19 @@ import org.eclipse.swt.widgets.TreeItem;
 import org.tizen.webuibuilder.ui.views.databinding.DataBindingDnDManager;
 import org.tizen.webuibuilder.ui.views.databinding.DataBindingView;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingData;
+import org.tizen.webuibuilder.ui.views.databinding.model.BindingObject;
 import org.tizen.webuibuilder.ui.views.databinding.model.TreeItemData;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
 
 public class SetSourcePage extends Dialog {
 
-       private DataBindingView view;
        private Shell shell;
        private TreeItem dataSourceTreeItem;
+       private BindingData dataSource;
 
        private StackLayout setttingStackLayout;
        private StackLayout dataStackLayout;
@@ -104,11 +108,10 @@ public class SetSourcePage extends Dialog {
         * @param view
         * @param dataSourceTreeItem
         */
-       public SetSourcePage( Shell parent, DataBindingView view, TreeItem dataSourceTreeItem ){
+       public SetSourcePage( Shell parent, TreeItem dataSourceTreeItem ){
                super( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL );
                setText( "Set Source" );
                this.dataSourceTreeItem = dataSourceTreeItem;
-               this.view = view;
        }
 
        /**
@@ -116,7 +119,7 @@ public class SetSourcePage extends Dialog {
         * 
         * @return message
         */
-       public String open() {
+       public BindingData open() {
                // Create the dialog window
                shell = new Shell( getParent(), SWT.TITLE | SWT.CLOSE | SWT.BORDER | SWT.RESIZE );
                shell.setText( getText() );
@@ -136,7 +139,8 @@ public class SetSourcePage extends Dialog {
                                display.sleep();
                        }
                }
-               return message;
+
+               return dataSource;
        }
 
        /**
@@ -219,30 +223,67 @@ public class SetSourcePage extends Dialog {
 
                                dataSourceTreeItem.removeAll();
 
-                               JsonObject root = new JsonObject();
                                TreeItem[] treeItems = dialogTree.getItems();
+                               
                                for (TreeItem item : treeItems) {
-                    Helper.makeJsonFromTree( item, root);
+                                   BindingObject bindingData = new BindingObject(item.getText(0), item.getText(1), item.getText(2));
+                                   makeBindingDataFromTree(item, bindingData);
+                                   dataModel.addDataSourceObjects(bindingData);
                 }
-                               Helper.makeTreeItem(root, null, dataSourceTreeItem, false);
-                               message = "OK";
+
+                               dataSource = dataModel;
                                shell.close();
                        }
                } );
-
-               // Set the OK button as the default, so
-               // user can type input and press Enter
-               // to dismiss
-               // shell.setDefaultButton(okButton);
        }
        
+       private void makeBindingDataFromTree(TreeItem parentItem, BindingObject parentBindingObject) {
+        String type = parentItem.getText(2);
+        
+        TreeItem[] items = parentItem.getItems();
+
+        if( type.equals("Array") ){
+            for(TreeItem item : items ){
+                if( item.getText(2).equals( "Index" ) ){
+                    for ( TreeItem subItem : item.getItems() ) {
+                        
+                        if( subItem.getText(0).trim().length() == 0 )
+                            continue;
+                        
+                        BindingObject bindingData = new BindingObject(subItem.getText(0), subItem.getText(1), subItem.getText(2));
+                        parentBindingObject.add(bindingData);
+                        makeBindingDataFromTree(subItem, bindingData);
+                    }
+                    break;
+                }else{
+                    BindingObject bindingData = new BindingObject(item.getText(0), item.getText(1), item.getText(2));
+                    parentBindingObject.add(bindingData);
+                    makeBindingDataFromTree(item, bindingData);
+                }
+            }
+        }else{
+            for ( TreeItem item : items ) {
+                BindingObject bindingData = new BindingObject(item.getText(0), item.getText(1), item.getText(2));
+                parentBindingObject.add(bindingData);
+                makeBindingDataFromTree(item, bindingData);
+            }
+        }
+    }
+       
        private void loadParentData(TreeItemData treeItemData) {
            BindingData dataModel = treeItemData.getModel();
            currentSubPage =null;
+           int settingWeight = 3;
+        int shshWidth =1;
+        Composite dataCompositeParent = dataModelGroup;
+        
         if (dataModel != null) {
             if (dataModel.getModelType().equals("STATIC")) {
                 dataTypeCombo.select(0);
                 currentSubPage = staticSubPage;
+                settingWeight = 0;
+                shshWidth = 0;
+                dataCompositeParent = staticSubPage.getDataComposite();
             } else if (dataModel.getModelType().equals("REMOTE CALL")) {
                 dataTypeCombo.select(1);
                 currentSubPage = remoteCallSubPage;
@@ -254,6 +295,11 @@ public class SetSourcePage extends Dialog {
                 currentSubPage = fileSystemSubPage;
             }
             
+            sashForm.setWeights(new int[] {2, settingWeight});
+            sashForm.setSashWidth(shshWidth);
+            dataComposite.setParent( dataCompositeParent );
+            dataComposite.getParent().layout();
+            
             Composite settingComposite = currentSubPage.getSettingComposite();
             setttingStackLayout.topControl = settingComposite;
             currentSubPage.setButtonsState(dataButtonMap);
index a399b25..5fcb0cb 100644 (file)
@@ -378,8 +378,8 @@ public class StaticSubPage implements SourceDialogSubPage {
         
         jsonFile = dataModel.getStaticFilePath();
         
-        if( json != null )
-            Helper.makeTreeItem(json, parentDataTree, null, true);
+//        if( json != null )
+//            Helper.makeTreeItem(json, parentDataTree, null, true);
     }
 
     public Composite getDataComposite() {