Package com.volantis.mcs.eclipse.builder.common.policies

Examples of com.volantis.mcs.eclipse.builder.common.policies.PolicyFileAccessor


    public synchronized void loadResource(IFile file) throws PolicyFileAccessException {
        // Only load if there is no model associated with the context, to
        // prevent multiple tabs of the same editor forcing multiple loads.
        if (getInteractionModel() == null) {
            setProject(file.getProject());
            PolicyFileAccessor policyFileAccessor = getPolicyFileAccessor();

            // Load the policy and grow the proxy
            PolicyBuilder policy = policyFileAccessor.loadPolicy(file);
            policy = preProcessPolicy(policy);
            final Proxy proxy = policyFileAccessor.wrapPolicy(policy,
                    getModelDescriptor(), getProject());

            // Revalidate the model on all changes
            proxy.validate();
            proxy.addListener(
View Full Code Here


     * 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);
            }
        };
    }
View Full Code Here

            // project associated with this Wizard
            if (!project.hasNature(MCSProjectNature.NATURE_ID)) {
                addMCSProjectNatureToProject();
            }

            PolicyFileAccessor accessor = POLICY_FILE_ACCESSOR_FACTORY.getPolicyFileAccessor(project);

            // Create the policy
            final CreatePolicyConfiguration configuration;
            if (MCSProjectNature.getCollaborativeWorking(project)) {
                configuration = new CollaborativeCreatePolicyConfiguration(
                    null, creationPage.isInitiallyLocked());
            } else {
                configuration = new GenericCreatePolicyConfiguration(null);
            }
            newPolicy = (IFile) accessor.createPolicy(newPolicyPath,
                                policyBuilder, configuration);
            if (newPolicy == null) {
                // the policy could not be created because it already exists,
                // so use the existing one.
                newPolicy = ResourcesPlugin.getWorkspace().getRoot().
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.builder.common.policies.PolicyFileAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.