@Override public Object getDefaultProperty(String propertyName) { if (LAYOUT_TEMPLATE_NAME.equals(propertyName)) { return "New Template"; //$NON-NLS-1$ } else if (LAYOUT_TEMPLATE_ID.equals(propertyName)) { String name = getStringProperty(LAYOUT_TEMPLATE_NAME); if (!CoreUtil.isNullOrEmpty(name)) { return name.replaceAll("[^a-zA-Z0-9]+", StringPool.EMPTY).toLowerCase(); // $NON-NLS-1$ } } else if (LAYOUT_TEMPLATE_FILE.equals(propertyName)) { return "/" + getStringProperty(LAYOUT_TEMPLATE_ID) + ".tpl"; // $NON-NLS-1$//$NON-NLS-2$ } else if (LAYOUT_WAP_TEMPLATE_FILE.equals(propertyName)) { return "/" + getStringProperty(LAYOUT_TEMPLATE_ID) + ".wap.tpl"; // $NON-NLS-1$//$NON-NLS-2$ } else if (LAYOUT_THUMBNAIL_FILE.equals(propertyName)) { return "/" + getStringProperty(LAYOUT_TEMPLATE_ID) + ".png"; // $NON-NLS-1$//$NON-NLS-2$ } else if (LAYOUT_IMAGE_BLANK_COLUMN.equals(propertyName)) { return true; } else if (LAYOUT_IMAGE_1_COLUMN.equals(propertyName) || LAYOUT_IMAGE_1_2_1_COLUMN.equals(propertyName) || LAYOUT_IMAGE_1_2_I_COLUMN.equals(propertyName) || LAYOUT_IMAGE_1_2_II_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_2_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_I_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_II_COLUMN.equals(propertyName) || LAYOUT_IMAGE_2_III_COLUMN.equals(propertyName) || LAYOUT_IMAGE_3_COLUMN.equals(propertyName)) { return false; } return super.getDefaultProperty(propertyName); }
@Override public IStatus validate(String propertyName) { if (LAYOUT_TEMPLATE_ID.equals(propertyName)) { // first check to see if an existing property exists. LayoutTplDescriptorHelper helper = new LayoutTplDescriptorHelper(getTargetProject()); if (helper.hasTemplateId(getStringProperty(propertyName))) { return LayoutTplCore.createErrorStatus(Msgs.templateIdExists); } // to avoid marking text like "this" as bad add a z to the end of the string String idValue = getStringProperty(propertyName) + "z"; // $NON-NLS-1$ if (CoreUtil.isNullOrEmpty(idValue)) { return super.validate(propertyName); } IStatus status = JavaConventions.validateFieldName( idValue, CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5); if (!status.isOK()) { return LayoutTplCore.createErrorStatus(Msgs.templateIdInvalid); } } else if (LAYOUT_TEMPLATE_FILE.equals(propertyName)) { final IPath filePath = new Path(getStringProperty(LAYOUT_TEMPLATE_FILE)); if (checkDocrootFileExists(filePath)) { return LayoutTplCore.createWarningStatus(Msgs.templateFileExists); } } else if (LAYOUT_WAP_TEMPLATE_FILE.equals(propertyName)) { final IPath filePath = new Path(getStringProperty(LAYOUT_WAP_TEMPLATE_FILE)); if (checkDocrootFileExists(filePath)) { return LayoutTplCore.createWarningStatus(Msgs.wapTemplateFileExists); } } else if (LAYOUT_THUMBNAIL_FILE.equals(propertyName)) { final IPath filePath = new Path(getStringProperty(LAYOUT_THUMBNAIL_FILE)); if (checkDocrootFileExists(filePath)) { return LayoutTplCore.createWarningStatus(Msgs.thumbnailFileExists); } } return super.validate(propertyName); }