PROP: Bug fix the custom event in the action tab 40/20840/1
authorjaeyeol lee <jaeyeol148.lee@samsung.com>
Tue, 13 May 2014 06:49:42 +0000 (15:49 +0900)
committerjaeyeol lee <jaeyeol148.lee@samsung.com>
Tue, 13 May 2014 06:49:42 +0000 (15:49 +0900)
save, refresh fixed

Change-Id: I964bc5650f537d006f67691c9117640933296056
Signed-off-by: jaeyeol lee <jaeyeol148.lee@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomActionAdderComposite.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomEventComposite.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionRunJavaScriptComposite.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionTab.java

index d51d8ae..4e17c5e 100644 (file)
@@ -24,7 +24,9 @@
 package org.tizen.webuibuilder.ui.views.properties.action;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.gef.commands.CommandStack;
 import org.eclipse.swt.SWT;
@@ -42,6 +44,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
 import org.tizen.webuibuilder.BuilderConstants;
 import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.descriptors.EventDescriptor;
 import org.tizen.webuibuilder.utility.ResourceManager;
 
 
@@ -57,16 +60,18 @@ public class ActionCustomActionAdderComposite extends Composite {
 //    private Composite clientComposite;
     private List<ActionCustomEventComposite> actionSelectionBars =
             new ArrayList<ActionCustomEventComposite>();
+    private List<EventDescriptor> events;
 
     private static String displayLabel = "Custom Actions";
 //    private int triggerCount = 0;
 
-    public ActionCustomActionAdderComposite(Composite parent, int style, Part model,
+    public ActionCustomActionAdderComposite(Composite parent, int style, List<EventDescriptor> events, Part model,
             CommandStack commandStack) {
         super(parent, style);
         this.model = model;
         this.parentComposite = parent;
         this.commandStack = commandStack;
+        this.events = events;
 
         this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
 
@@ -171,6 +176,17 @@ public class ActionCustomActionAdderComposite extends Composite {
         }
         return bar;
     }
+    
+    public ActionCustomEventComposite addCustomActionBar(String cuntomEventName) {
+        ActionCustomEventComposite bar;
+        bar = new ActionCustomEventComposite(this, SWT.NONE, cuntomEventName, model, commandStack);
+        if (bar != null) {
+            bar.setLayoutData(new GridData(GridData.FILL_BOTH));
+            bar.setUiRefresh();
+            actionSelectionBars.add(bar);
+        }
+        return bar;
+    }
 
     public void upLayout() {
         parentComposite.layout();
@@ -183,5 +199,31 @@ public class ActionCustomActionAdderComposite extends Composite {
 
         upLayout();
     }
+    
+    /**
+     * prepare to ui refresh
+     */
+    public void setUiRefresh() {
+        Map<String, List<String>> eventMap = new HashMap<String, List<String>>();
+        eventMap.putAll(model.getEvents());
+                
+        if (events != null) {
+            for (EventDescriptor event : events) {
+                if (eventMap.containsKey(event.getEventName())) {
+                    eventMap.remove(event.getEventName());
+                }
+            }
+            
+        }
+        
+        if ((eventMap != null) && (!eventMap.isEmpty())) {
+            Object[] customEvents = eventMap.keySet().toArray();
+            for (Object customEvent : customEvents) {
+                addCustomActionBar(customEvent.toString());
+                upLayout();
+            }
+        }
+
+    }
 
 }
index 02ac77a..1bba111 100644 (file)
@@ -42,6 +42,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Text;
 import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.GotoPageProperty;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.utility.ResourceManager;
 
@@ -274,4 +275,34 @@ public class ActionCustomEventComposite extends ActionEventComposite {
 
         return index;
     }
+    
+    /**
+     * prepare to ui refresh
+     */
+    public void setUiRefresh() {
+//        ActionSelectBarComposite bar = addSelectionBar(text_2.getText());
+//        bar.setEventHandlerUiRefresh();
+//        upLayout();
+        
+        List<String> values = model.getEventValues(customTriggerName);
+
+        if (values != null) {
+            for (int i = 0; i < values.size(); i++) {
+                ActionSelectBarComposite bar = addSelectionBar(customTriggerName);
+                bar.setEventHandlerUiRefresh();
+            }
+        }
+
+        GotoPageProperty value = model.getGotoPageproperty(customTriggerName);
+        if (value != null) {
+            ActionSelectBarComposite bar = addSelectionBar(customTriggerName);
+            bar.setGotoPageUiRefresh();
+        }
+        
+        String urlValue = model.getOpenUrlEventValues(customTriggerName);
+        if (urlValue != null) {
+            ActionSelectBarComposite bar = addSelectionBar(customTriggerName);
+            bar.setOpenUrlUiRefresh();
+        }
+    }
 }
index 15c12ac..e93bb7f 100644 (file)
@@ -68,7 +68,7 @@ public class ActionRunJavaScriptComposite extends Composite implements IActionAc
     private HandlerCodeWriter codeWriter;
     private List<Composite> childComposites = new ArrayList<Composite>();
     private int index;
-    private String customEvent;
+    private String customEvent = null;
 
     /**
      * @param parent
@@ -180,7 +180,7 @@ public class ActionRunJavaScriptComposite extends Composite implements IActionAc
 
         setValidatedValue(handlerName);
         this.oldComboText = combo.getText();
-
+        this.customEvent = PropertiesConstant.EVENT_PREFIX + eventName;
         addListenersToCombo();
     }
 
@@ -334,8 +334,13 @@ public class ActionRunJavaScriptComposite extends Composite implements IActionAc
                 }
             }
 
-            trigger.getCommandStack().execute(new SetPartEventCommand(trigger.getModel(), trigger
-                                                      .getTriggerNameSrc(), value, index));
+            if (customEvent != null) {
+                trigger.getCommandStack().execute(new SetPartEventCommand(trigger.getModel(), customEvent, value, index));
+            } else {
+                trigger.getCommandStack().execute(new SetPartEventCommand(trigger.getModel(), trigger
+                                                                          .getTriggerNameSrc(), value, index));
+            }
+            
         }
     }
 
index 3d05f7a..8f35a05 100644 (file)
@@ -261,12 +261,10 @@ public class ActionTab extends PropertiesTabItem {
             if (events == null) {
                 return;
             }
-
-            ActionEventComposite actionEventComposite;
             
             // check already exist event handler in model
             for (EventDescriptor event : events) {
-                actionEventComposite =
+                ActionEventComposite actionEventComposite =
                         new ActionEventComposite(content, SWT.NONE, event, toolkit, model,
                                                  commandStack);
                 actionEventComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
@@ -280,8 +278,9 @@ public class ActionTab extends PropertiesTabItem {
                 actionEventComposite.setUiRefresh(actionAnimation);
             }
             customActionAdder =
-                    new ActionCustomActionAdderComposite(content, SWT.NONE, model, commandStack);
+                    new ActionCustomActionAdderComposite(content, SWT.NONE, events, model, commandStack);
             customActionAdder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+            customActionAdder.setUiRefresh();
         }
 
         resizeScrolledComposite();