* ODOM where necessary before saving.
*
* @return A policy file accessor for this layout
*/
public PolicyFileAccessor getPolicyFileAccessor() {
final PolicyFileAccessor underlying = super.getPolicyFileAccessor();
return new PolicyFileAccessor() {
public IResource createPolicy(IPath location, PolicyBuilder policy, CreatePolicyConfiguration configuration) throws PolicyFileAccessException {
return underlying.createPolicy(location, policy, configuration);
}
public void deletePolicy(IResource policyResource) throws PolicyFileAccessException {
underlying.deletePolicy(policyResource);
}
public void renamePolicy(IResource policyResource, IPath destination) throws PolicyFileAccessException {
underlying.renamePolicy(policyResource, destination);
}
public void savePolicy(PolicyBuilder policy, IResource policyResource, IProgressMonitor monitor) throws PolicyFileAccessException {
try {
final Set entries = variantBuilderProxyToRootElement.entrySet();
for (Iterator iter = entries.iterator(); iter.hasNext(); ) {
final Map.Entry entry = (Map.Entry) iter.next();
final BeanProxy variantBuilderProxy =
(BeanProxy) entry.getKey();
final Proxy contentBuilderProxy =
variantBuilderProxy.getPropertyProxy(PolicyModel.CONTENT);
if (VariantType.NULL == variantBuilderProxy.getPropertyProxy(
PolicyModel.VARIANT_TYPE).getModelObject()) {
contentBuilderProxy.setModelObject(null);
} else if (!contentBuilderProxy.isReadOnly()) {
final ODOMElement element = (ODOMElement) entry.getValue();
final ContentBuilder contentBuilder = documentToBuilder(
element.getDocument(), contentBuilderProxy);
contentBuilderProxy.setModelObject(contentBuilder);
}
}
} catch (IOException e) {
throw new PolicyFileAccessException(e);
}
underlying.savePolicy(policy, policyResource, monitor);
}
public PolicyBuilder loadPolicy(IResource policyResource) throws PolicyFileAccessException {
return underlying.loadPolicy(policyResource);
}
public Proxy wrapPolicy(PolicyBuilder builder, ModelDescriptor descriptor, IProject project) throws PolicyFileAccessException {
return underlying.wrapPolicy(builder, descriptor, project);
}
public void updatePolicyProxyState(Proxy proxy, IProject project) throws PolicyFileAccessException {
underlying.updatePolicyProxyState(proxy, project);
}
};
}