</type>
<type id="attrtext@databinding">
- <constant value="attr" displayName=""/>
+ <constant value="attr" displayName="form"/>
+ <constant value="attr" displayName="for"/>
<constant value="text" displayName=""/>
</type>
</types>
\ No newline at end of file
</property> -->
<property name="for" type="string" displayName="For" default=""/>
- <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
+ <property name="data-bind" type="attrtext@databinding" displayName="Data Binding" default="" initValue=""/>
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
package org.tizen.webuibuilder.gef.policies;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
import org.tizen.webuibuilder.ui.editor.dnd.listener.PageDesignerDropTargetListener;
import org.tizen.webuibuilder.ui.editor.ruler.DesignerGuide;
import org.tizen.webuibuilder.ui.editor.ruler.commands.ChangeGuideCommand;
+import org.tizen.webuibuilder.ui.views.databinding.DataBindingTooltipParser;
public class DesignerXYLayoutEditPolicy extends HoverViewerXYLayoutEditPolicy {
SWT.POP_UP);
for (int i = 0; i < list.size(); i++) {
- MenuItem item = new MenuItem(contextMenu, SWT.PUSH);
- String value = list.get(i).getValue();
- String displayName = list.get(i).getDisplayName();
- final String str;
+ final MenuItem item = new MenuItem(contextMenu, SWT.PUSH);
+ final String value = list.get(i).getValue();
+ final String displayName = list.get(i).getDisplayName();
if ((displayName != null) && (!displayName.isEmpty())) {
item.setText(displayName);
- str =
- value + ": { " + displayName + ": " + property2.getValue()
- + " }";
} else {
item.setText(value);
- str = value + ": " + property2.getValue();
}
item.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
+ String str = targetPart.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
+ final String info = makeInfoString(property2, displayName, value, str);
command =
new SetPartPropertyCommand(targetPart, BuilderConstants.ATTRIBUTE_DATA_BIND,
- str);
+ info);
}
});
}
return command;
}
+
+ private String makeInfoString(PartProperty property2, String displayName, String value, String str) {
+ String string = "";
+
+ if ((str != null) && (!str.isEmpty())) {
+ Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(str);
+
+ if (bindingInfos.containsKey(value)) {
+ bindingInfos.remove(value);
+ } else if (bindingInfos.containsKey("attr-"+displayName)) {
+ bindingInfos.remove("attr-"+displayName);
+ }
+
+ if ((displayName != null) && (!displayName.isEmpty())) {
+ bindingInfos.put(value+"-"+displayName, property2.getValue());
+ } else {
+ bindingInfos.put(value, property2.getValue());
+ }
+
+ string = DataBindingTooltipParser.makeStringFromMap(bindingInfos);
+ } else {
+ if ((displayName != null) && (!displayName.isEmpty())) {
+ string = value + ": { " + displayName + ": " + property2.getValue() + " }";
+ } else {
+ string = value + ": " + property2.getValue();
+ }
+ }
+
+ return string;
+ }
+
private boolean hasProperty(EditPart editPart, String name) {
if (editPart == null) {
return false;
public void valueChanged(Part part, String attributeDataBind,
String value, boolean undoable) {
- commandStack.execute(new SetPartPropertyCommand(part, BuilderConstants.ATTRIBUTE_DATA_BIND, "", true));
+ commandStack.execute(new SetPartPropertyCommand(part, BuilderConstants.ATTRIBUTE_DATA_BIND, value, true));
}
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.gef.EditPart;
if (part.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND) != null) {
String propertyValue =
part.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
+
if ((propertyValue != null) && (!propertyValue.isEmpty())) {
- String[] str = propertyValue.split(": ");
- if (str[1].startsWith(BuilderConstants.DATABINDING_ARRAYITEM_VALUE_PREFIX)) {
- String parentPropertyValue = getParentPropertyValue(part, str[1]);
- if (parentPropertyValue != null) {
- addInfoTableItem(part, parentPropertyValue, part.getIdPropertyValue(),
- str[0]);
+ Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(propertyValue);
+ Object[] bindingTypes = bindingInfos.keySet().toArray();
+ for (Object bindingType : bindingTypes) {
+ String key = bindingType.toString();
+ String modelValue = bindingInfos.get(key);
+ if (modelValue.startsWith(BuilderConstants.DATABINDING_ARRAYITEM_VALUE_PREFIX)) {
+ String parentPropertyValue = getParentPropertyValue(part, modelValue);
+ if (parentPropertyValue != null) {
+ addInfoTableItem(part, parentPropertyValue, part.getIdPropertyValue(),
+ key);
+ }
+ } else {
+ addInfoTableItem(part, modelValue, part.getIdPropertyValue(), key);
}
- } else {
- addInfoTableItem(part, str[1], part.getIdPropertyValue(), str[0]);
}
}
}
* @param item
* @param editor
*/
- public void removeInfoTableItem(Part part) {
+ public void removeInfoTableItem(Part part, String bindingInfo) {
if (delegater != null) {
- delegater.valueChanged(part, BuilderConstants.ATTRIBUTE_DATA_BIND, "", true);
+ delegater.valueChanged(part, BuilderConstants.ATTRIBUTE_DATA_BIND, bindingInfo, true);
}
}
TableItem[] tableItems = infoTableViewer.getTable().getSelection();
for (TableItem tableItem : tableItems) {
Part part = (Part) tableItem.getData("PART");
+ String tableTypeValue = tableItem.getText(2);
if (part != null) {
- removeInfoTableItem(part);
+ String propertyValue =
+ part.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
+ if ((propertyValue != null) && (!propertyValue.isEmpty())) {
+ Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(propertyValue);
+ Object[] bindingTypes = bindingInfos.keySet().toArray();
+ for (Object bindingType : bindingTypes) {
+ if ((tableTypeValue != null) && (bindingType.toString().equals(tableTypeValue))) {
+ bindingInfos.remove(bindingType);
+ removeInfoTableItem(part, DataBindingTooltipParser.makeStringFromMap(bindingInfos));
+ }
+ }
+ }
}
}
}
if (pageDesigner != null) {
List<BindingData> models = pageDesigner.getAppManager().getViewModels();
for (BindingData model : models) {
- if (model.getSourceName().equals(e.getOldValue())) {
+ if ((model.getSourceName() != null)&&(model.getSourceName().equals(e.getOldValue()))) {
model.setSourceName(e.getValue());
}
}
package org.tizen.webuibuilder.ui.views.databinding;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.activation.CommandInfo;
}
return sample;
}
+
+ public static Map<String, String> parseToMap(String str) {
+ Map<String, String> bindingInfos = new HashMap<String, String>();
+ if ((str.contains("attr: { ")) && (!str.startsWith("attr: { "))) {
+ String[] temps = str.split("attr: \\{ ");
+ if ((temps[0] != null) && (!temps[0].isEmpty())) {
+ String[] infos = temps[0].split(", ");
+ for (String info : infos) {
+ put(bindingInfos, info);
+ }
+
+ if ((temps.length > 1) && (temps[1] != null) && (!temps[1].isEmpty())) {
+ temps[1] = temps[1].replaceAll("attr:", "");
+ temps[1] = temps[1].replaceAll(" \\{ ", "");
+ temps[1] = temps[1].replaceAll(" }", "");
+
+ String[] infos2 = temps[1].split(", ");
+ for (String info : infos2) {
+ info = new StringBuffer(info).insert(0, "attr-").toString();
+ put(bindingInfos, info);
+ }
+ }
+ }
+ } else if ((str.contains("attr: { ")) && (str.startsWith("attr: { "))) {
+ String[] temps = str.split(" }, ");
+ if ((temps[0] != null) && (!temps[0].isEmpty())) {
+ temps[0] = temps[0].replaceAll("attr:", "");
+ temps[0] = temps[0].replaceAll(" \\{ ", "");
+ temps[0] = temps[0].replaceAll(" }", "");
+
+ String[] infos2 = temps[0].split(", ");
+ for (String info : infos2) {
+ info = new StringBuffer(info).insert(0, "attr-").toString();
+ put(bindingInfos, info);
+ }
+ if ((temps.length > 1) && (temps[1] != null) && (!temps[1].isEmpty())) {
+ String[] infos = temps[1].split(", ");
+ for (String info : infos) {
+ put(bindingInfos, info);
+ }
+ }
+ }
+ } else {
+ if (str.contains(", ")) {
+ String[] infos = str.split(", ");
+ for (String info : infos) {
+ put(bindingInfos, info);
+ }
+ } else {
+ put(bindingInfos, str);
+ }
+ }
+ return bindingInfos;
+ }
+
+ private static void put(Map<String, String> bindingInfos, String string) {
+ String[] infos = string.split(": ");
+ if ((infos[0] != null) && (!infos[0].isEmpty())) {
+ if ((infos[1] != null) && (!infos[1].isEmpty())) {
+ bindingInfos.put(infos[0], infos[1]);
+ }
+ }
+
+ }
+
+ public static String makeStringFromMap(Map<String, String> bindingInfos) {
+ Object[] bindingTypes = bindingInfos.keySet().toArray();
+ String string = "";
+ for (Object bindingType : bindingTypes) {
+ String key = bindingType.toString();
+ String modelValue = bindingInfos.get(key);
+ if (key.startsWith("attr-")) {
+ key = key.replaceAll("attr-", "");
+ if (string.contains("attr")) {
+ int index = string.lastIndexOf(" }");
+ string = new StringBuffer(string).insert(index, ", " + key + ": " + modelValue).toString();
+ } else {
+ if (!string.isEmpty()) {
+ string += ", ";
+ }
+ string += "attr: { " + key + ": " + modelValue + " }";
+ }
+ } else {
+ if (!string.isEmpty()) {
+ string += ", ";
+ }
+ string += key + ": " + modelValue;
+ }
+ }
+
+ return string;
+ }
}