import org.eclipse.gef.commands.Command;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.WidgetValidator;
import org.tizen.webuibuilder.model.app.AppManagerForHTML;
import org.tizen.webuibuilder.model.filedata.PageFileData;
import org.tizen.webuibuilder.model.page.PageData;
pageDatas = new ArrayList<PageData>(size);
for(int i = 0; i < size; i++) {
+ String propertyId = pageFileData.getName(i);
+ Part part = pageFileData.getRootPart(i);
+ Part baseRootPart = appManager.getPageDataSet().getBaseRootPart();
+
+ if ( propertyId == null ||
+ (propertyId != null &&
+ !part.canSetPropertyValue(baseRootPart, BuilderConstants.PROPERTY_ID, propertyId).equals(WidgetValidator.OK))) {
+ String newId = part.getNewIdProperty(baseRootPart);
+ part.setPropertyValue(BuilderConstants.PROPERTY_ID, newId, false);
+ pageFileData.setName(i, newId);
+ part.getElement().setAttribute(BuilderConstants.PROPERTY_ID, newId);
+ }
+
PageData pageData = new PageDataForHTML(BuilderConstants.EMPTY,
pageFileData, i, appManager.getDocument(),
appManager.getDescriptorManager(), null);
* @return OK if property value can be set, and error message otherwise
*/
public String canSetPropertyValue(Part part, String propertyName, String value) {
- if (part == null) {
+ return canSetPropertyValue(part, null, propertyName, value);
+ }
+
+ /**
+ * Returns OK if property value can be set.
+ *
+ * @param part
+ * a {@link Part}
+ * @param parent
+ * a part to be parent {@link Part}
+ * @param propertyName
+ * a property name
+ * @param value
+ * a property value
+ * @return OK if property value can be set, and error message otherwise
+ */
+ public String canSetPropertyValue(Part part, Part parent,
+ String propertyName, String value) {
+ if (part == null) {
// This case should not be happened.
return ERROR;
}
break;
}
- String message = checkPropertyConditions(part, desc.getConditionDescriptors(), value);
+ String message = checkPropertyConditions(part, parent, desc.getConditionDescriptors(), value);
return message;
- }
+ }
- /**
+ /**
* Returns OK if property value can be set.
*
* @param condition
*
* @param part
* a {@link Part}
+ * @param parent
+ * a part to be parent {@link Part}
* @param conditions
* a List containing {@link ConditionDescriptor}
* @param value
* a property value to check validity
* @return OK if property condition is valid, and error message otherwise
*/
- private String checkPropertyConditions(Part part, List<PropertyConditionDescriptor> conditions,
- String value) {
- if (conditions == null) {
+ private String checkPropertyConditions(Part part, Part parent,
+ List<PropertyConditionDescriptor> conditions, String value) {
+ if (conditions == null) {
// This case should not be happened.
return ERROR;
}
-
- int size = conditions.size();
+
+ int size = conditions.size();
if (size == 0) {
return OK;
}
for (int i = 0; i < size; i++) {
- String message = checkPropertyCondition(part, conditions.get(i), value);
+ String message = checkPropertyCondition(part, parent, conditions.get(i), value);
if (message != OK) {
return message;
}
}
return OK;
- }
+ }
/**
* Returns OK if property condition is valid.
*
* @param part
* a {@link Part}
+ * @param parent
+ * a part to be parent {@link Part}
* @param condition
* a {@link ConditionDescriptor}
* @param value
* a property value to check validity
* @return OK if property condition is valid, and error message otherwise
*/
- private String checkPropertyCondition(Part part, PropertyConditionDescriptor condition,
- String value) {
- if (part == null || condition == null || value == null) {
- // This case should not be happened.
- return ERROR;
- }
-
- String name = condition.getName();
- String error = condition.getError();
-
- if (name.equals(PropertyConditionDescriptor.STRING_ID)) {
- if (!checkIdValue(value)) {
- return BuilderMessages.ERROR_ID_INVALID;
- }
- Part doc = part.getOwnerDocument();
- if (doc != null) {
- if (!searchUsedPropertyValue(part, doc, BuilderConstants.PROPERTY_ID, value, false)) {
- return getErrorMessage(error);
- }
- }
-
- Part pagepart = part.getOwnerPage();
- if (pagepart != null) {
- if (!searchUsedPropertyValue(part, pagepart, BuilderConstants.PROPERTY_ID, value,
- true)) {
- return getErrorMessage(error);
- }
- }
- } else if (name.equals(PropertyConditionDescriptor.STRING_MAX_LENGTH)) {
- String conditionValue = condition.getValue();
- int length = Long.valueOf(conditionValue).intValue();
-
- if (value.length() > length) {
- return NLS.bind(getErrorMessage(error), conditionValue);
- }
- } else if (name.equals(PropertyConditionDescriptor.INTEGER_MIN)) {
- String conditionValue = condition.getValue();
-
- if (!checkMinValue(value, conditionValue)) {
- return NLS.bind(getErrorMessage(error), conditionValue);
- }
- } else if (name.equals(PropertyConditionDescriptor.INTEGER_MAX)) {
- String conditionValue = condition.getValue();
-
- if (!checkMaxValue(value, conditionValue)) {
- return NLS.bind(getErrorMessage(error), conditionValue);
- }
- }
-
- return OK;
+ private String checkPropertyCondition(Part part, Part parent,
+ PropertyConditionDescriptor condition, String value) {
+ if (part == null || condition == null || value == null) {
+ // This case should not be happened.
+ return ERROR;
+ }
+
+ String name = condition.getName();
+ String error = condition.getError();
+
+ if (name.equals(PropertyConditionDescriptor.STRING_ID)) {
+ if (!checkIdValue(value)) {
+ return BuilderMessages.ERROR_ID_INVALID;
+ }
+
+ Part docPart = null;
+ Part pagePart = null;
+
+ if(parent != null) {
+ docPart = (part.isDocumentPart()) ? part : parent.getOwnerDocument();
+ pagePart = (part.isPagePart()) ? part : parent.getOwnerPage();
+ } else {
+ docPart = part.getOwnerDocument();
+ pagePart = part.getOwnerPage();
+ }
+
+ if (docPart != null) {
+ if (!searchUsedPropertyValue(part, docPart, BuilderConstants.PROPERTY_ID, value, false)) {
+ return getErrorMessage(error);
+ }
+ }
+
+ if (pagePart != null) {
+ if (!searchUsedPropertyValue(part, pagePart, BuilderConstants.PROPERTY_ID, value,
+ true)) {
+ return getErrorMessage(error);
+ }
+ }
+ } else if (name.equals(PropertyConditionDescriptor.STRING_MAX_LENGTH)) {
+ String conditionValue = condition.getValue();
+ int length = Long.valueOf(conditionValue).intValue();
+
+ if (value.length() > length) {
+ return NLS.bind(getErrorMessage(error), conditionValue);
+ }
+ } else if (name.equals(PropertyConditionDescriptor.INTEGER_MIN)) {
+ String conditionValue = condition.getValue();
+
+ if (!checkMinValue(value, conditionValue)) {
+ return NLS.bind(getErrorMessage(error), conditionValue);
+ }
+ } else if (name.equals(PropertyConditionDescriptor.INTEGER_MAX)) {
+ String conditionValue = condition.getValue();
+
+ if (!checkMaxValue(value, conditionValue)) {
+ return NLS.bind(getErrorMessage(error), conditionValue);
+ }
+ }
+
+ return OK;
}
+
/**
* Returns an error message corresponding to the key.
*