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;
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;
// 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));
}
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();
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();
+ }
+ }
+
+ }
}
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;
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();
+ }
+ }
}
private HandlerCodeWriter codeWriter;
private List<Composite> childComposites = new ArrayList<Composite>();
private int index;
- private String customEvent;
+ private String customEvent = null;
/**
* @param parent
setValidatedValue(handlerName);
this.oldComboText = combo.getText();
-
+ this.customEvent = PropertiesConstant.EVENT_PREFIX + eventName;
addListenersToCombo();
}
}
}
- 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));
+ }
+
}
}
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));
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();