From d95c4deb1a92f65619b8ddb1a68673b76513b601 Mon Sep 17 00:00:00 2001 From: jaeyeol lee Date: Tue, 13 May 2014 15:49:42 +0900 Subject: [PATCH] PROP: Bug fix the custom event in the action tab save, refresh fixed Change-Id: I964bc5650f537d006f67691c9117640933296056 Signed-off-by: jaeyeol lee --- .../action/ActionCustomActionAdderComposite.java | 44 +++++++++++++++++++++- .../action/ActionCustomEventComposite.java | 31 +++++++++++++++ .../action/ActionRunJavaScriptComposite.java | 13 +++++-- .../ui/views/properties/action/ActionTab.java | 7 ++-- 4 files changed, 86 insertions(+), 9 deletions(-) diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomActionAdderComposite.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomActionAdderComposite.java index d51d8ae..4e17c5e 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomActionAdderComposite.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomActionAdderComposite.java @@ -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 actionSelectionBars = new ArrayList(); + private List 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 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> eventMap = new HashMap>(); + 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(); + } + } + + } } diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomEventComposite.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomEventComposite.java index 02ac77a..1bba111 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomEventComposite.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionCustomEventComposite.java @@ -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 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(); + } + } } diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionRunJavaScriptComposite.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionRunJavaScriptComposite.java index 15c12ac..e93bb7f 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionRunJavaScriptComposite.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionRunJavaScriptComposite.java @@ -68,7 +68,7 @@ public class ActionRunJavaScriptComposite extends Composite implements IActionAc private HandlerCodeWriter codeWriter; private List childComposites = new ArrayList(); 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)); + } + } } diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionTab.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionTab.java index 3d05f7a..8f35a05 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionTab.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/action/ActionTab.java @@ -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(); -- 2.7.4