Package com.volantis.mcs.policies.variants

Examples of com.volantis.mcs.policies.variants.VariantBuilder


            // Javadoc inherited
            public void visit(VariablePolicyBuilder policy) {
                boolean containsCSS = false;
                List builders = policy.getVariantBuilders();
                for (Object builderObject : builders) {
                    VariantBuilder builder = (VariantBuilder) builderObject;
                    if (builder.getVariantType() == VariantType.THEME) {
                        ContentBuilder variantContent =
                                builder.getContentBuilder();
                        InternalThemeContentBuilder themeContent =
                                (InternalThemeContentBuilder) variantContent;
                        if (themeContent.getStyleSheet() instanceof CSSStyleSheet) {
                            StyleSheet parsedStyleSheet =
                                    STYLE_SHEET_FACTORY.createStyleSheet(
View Full Code Here


    public void setPolicyBuilder(PolicyBuilder newBuilder) {
        // Get the previously selected variant builder so that we can attempt
        // to reselect it after the change.
        PolicyEditorContext context = (PolicyEditorContext) getContext();
        Proxy previousSelectedProxy = context.getSelectedVariant();
        VariantBuilder previouslySelectedBuilder =
                previousSelectedProxy == null ?
                null : (VariantBuilder) previousSelectedProxy.getModelObject();

        Proxy policyProxy = getContext().getInteractionModel();
        policyProxy.setReadWriteState(ReadWriteState.READ_WRITE);
        // Because the merge process may have modified the existing model
        // directly before calling this method, we must force the proxy's
        // structure to be updated to ensure new variants are added and
        // appropriate change events are fired.
        policyProxy.setModelObject(newBuilder, true);
        try {
            context.getPolicyFileAccessor().updatePolicyProxyState(
                    policyProxy, context.getProject());
        } catch (PolicyFileAccessException pfae) {
            EclipseCommonPlugin.logError(ABPlugin.getDefault(),
                    getClass(), pfae);
        }

        if (previouslySelectedBuilder == null) {
            context.setSelectedVariant(null);
        } else {
            BeanProxy modelProxy = (BeanProxy) context.getInteractionModel();
            ListProxy variants = (ListProxy)
                    modelProxy.getPropertyProxy(PolicyModel.VARIANTS);
            boolean setSelection = false;
            for (int i = 0; !setSelection && i < variants.size(); i++) {
                VariantBuilder builder = (VariantBuilder)
                        variants.getItemProxy(i).getModelObject();
                if (previouslySelectedBuilder.equals(builder)) {
                    context.setSelectedVariant((BeanProxy) variants.getItemProxy(i));
                    setSelection = true;
                }
View Full Code Here

                ListProxy variants = (ListProxy)
                        theme.getPropertyProxy(PolicyModel.VARIANTS);

                final VariantType variantType =
                    ((PolicyEditorContext) context).getDefaultVariantType();
                VariantBuilder newVariant = PolicyFactory.getDefaultInstance().
                        createVariantBuilder(variantType);
                if (variantType == VariantType.THEME) {
                    final ThemeContentBuilder contentBuilder =
                        InternalPolicyFactory.getInternalInstance().
                            createThemeContentBuilder();
                    newVariant.setContentBuilder(contentBuilder);
                }
                Operation addOperation =
                        variants.prepareAddModelItemOperation(newVariant);
                context.executeOperation(addOperation);
            }
View Full Code Here

     *
     * @param file The image file for which to create the builder
     * @return The builder
     */
    private VariantBuilder createVariant(File file) {
        VariantBuilder variant = POLICY_FACTORY.createVariantBuilder(VariantType.IMAGE);
        ImageMetaDataBuilder metaData = POLICY_FACTORY.createImageMetaDataBuilder();

        ImageData data = getImageData(file);
        if (data != null) {
            metaData.setHeight(data.height);
            metaData.setWidth(data.width);
            metaData.setPixelDepth(data.depth);
        }

        String extension = IOUtils.getExtension(file);
        Encoding imageEncoding = ImageEncoding.COLLECTION.
                getEncodingForExtension(extension);
        if (imageEncoding != null) {
            metaData.setImageEncoding((ImageEncoding) imageEncoding);
        }

        File root = new File(folderSelector.getText().getText());
        if (root.getPath().length() < file.getPath().length()) {
            String url = file.getPath().substring(root.getPath().length());
            URLContentBuilder content = POLICY_FACTORY.createURLContentBuilder();
            content.setURL(url);
            variant.setContentBuilder(content);
        }

        variant.setMetaDataBuilder(metaData);
        return variant;
    }
View Full Code Here

        IFile layoutIFile =
            (IFile) variantBuilderProxyToIFile.get(variantBuilderProxy);
        if (layoutIFile == null) {

            final VariantBuilder variantBuilder =
                (VariantBuilder) variantBuilderProxy.getModelObject();
            ContentBuilder contentBuilder = variantBuilder.getContentBuilder();

            if (contentBuilder == null) {
                final InternalLayoutContentBuilder layoutBuilder =
                    InternalPolicyFactory.getInternalInstance().
                        createLayoutContentBuilder();
View Full Code Here

        boolean readOnly = false;
        final BeanProxy selectedVariantProxy = getSelectedVariant();
        if (selectedVariantProxy == null) {
            readOnly = true;
        } else {
            final VariantBuilder selectedVariant =
                (VariantBuilder) selectedVariantProxy.getModelObject();
            if (selectedVariant == null) {
               readOnly = true;
            }
        }
View Full Code Here

    public void setPolicyBuilder(PolicyBuilder newBuilder) {
        // Get the previously selected variant builder so that we can attempt
        // to reselect it after the change.
        PolicyEditorContext context = (PolicyEditorContext) getContext();
        Proxy previousSelectedProxy = context.getSelectedVariant();
        VariantBuilder previouslySelectedBuilder =
                previousSelectedProxy == null ?
                null : (VariantBuilder) previousSelectedProxy.getModelObject();

        Proxy policyProxy = getContext().getInteractionModel();
        policyProxy.setReadWriteState(ReadWriteState.READ_WRITE);
        // Because the merge process may have modified the existing model
        // directly before calling this method, we must force the proxy's
        // structure to be updated to ensure new variants are added and
        // appropriate change events are fired.
        policyProxy.setModelObject(newBuilder, true);
        try {
            context.getPolicyFileAccessor().updatePolicyProxyState(
                    policyProxy, context.getProject());
        } catch (PolicyFileAccessException pfae) {
            EclipseCommonPlugin.logError(BuilderPlugin.getDefault(),
                    getClass(), pfae);
        }

        if (previouslySelectedBuilder == null) {
            context.setSelectedVariant(null);
        } else {
            BeanProxy modelProxy = (BeanProxy) context.getInteractionModel();
            ListProxy variants = (ListProxy)
                    modelProxy.getPropertyProxy(PolicyModel.VARIANTS);
            boolean setSelection = false;
            for (int i = 0; !setSelection && i < variants.size(); i++) {
                VariantBuilder builder = (VariantBuilder)
                        variants.getItemProxy(i).getModelObject();
                if (previouslySelectedBuilder.equals(builder)) {
                    context.setSelectedVariant((BeanProxy) variants.getItemProxy(i));
                    setSelection = true;
                }
View Full Code Here

     * @param variants A list of variants being created by this wizard
     */
    public void performFinish(List variants) {
        Iterator it = variants.iterator();
        while (it.hasNext()) {
            VariantBuilder variant = (VariantBuilder) it.next();
            SelectionBuilder selection = variant.getSelectionBuilder();
            if (selection instanceof TargetedSelectionBuilder) {
                TargetedSelectionBuilder targeted = (TargetedSelectionBuilder) selection;
                List categoryReferences = targeted.getModifiableCategoryReferences();
                List deviceReferences = targeted.getModifiableDeviceReferences();

View Full Code Here

    public void setPolicyBuilder(PolicyBuilder newBuilder) {
        // Get the previously selected variant builder so that we can attempt
        // to reselect it after the change.
        PolicyEditorContext context = (PolicyEditorContext) getContext();
        Proxy previousSelectedProxy = context.getSelectedVariant();
        VariantBuilder previouslySelectedBuilder =
                previousSelectedProxy == null ?
                null : (VariantBuilder) previousSelectedProxy.getModelObject();

        Proxy policyProxy = getContext().getInteractionModel();
        policyProxy.setReadWriteState(ReadWriteState.READ_WRITE);
        // Because the merge process may have modified the existing model
        // directly before calling this method, we must force the proxy's
        // structure to be updated to ensure new variants are added and
        // appropriate change events are fired.
        policyProxy.setModelObject(newBuilder, true);
        try {
            context.getPolicyFileAccessor().updatePolicyProxyState(
                    policyProxy, context.getProject());
        } catch (PolicyFileAccessException pfae) {
            EclipseCommonPlugin.logError(BuilderPlugin.getDefault(),
                    getClass(), pfae);
        }

        if (previouslySelectedBuilder == null) {
            context.setSelectedVariant(null);
        } else {
            BeanProxy modelProxy = (BeanProxy) context.getInteractionModel();
            ListProxy variants = (ListProxy)
                    modelProxy.getPropertyProxy(PolicyModel.VARIANTS);
            boolean setSelection = false;
            for (int i = 0; !setSelection && i < variants.size(); i++) {
                VariantBuilder builder = (VariantBuilder)
                        variants.getItemProxy(i).getModelObject();
                if (previouslySelectedBuilder.equals(builder)) {
                    context.setSelectedVariant((BeanProxy) variants.getItemProxy(i));
                    setSelection = true;
                }
View Full Code Here

    // Javadoc inherited
    public void performFinish(List variants) {
        super.performFinish(variants);
        Iterator it = variants.iterator();
        while (it.hasNext()) {
            VariantBuilder variant = (VariantBuilder) it.next();
            InternalLayoutContentBuilder content = (InternalLayoutContentBuilder)
                    ((InternalPolicyFactory) POLICY_FACTORY).createLayoutContentBuilder();
            LayoutType type = null;
            Object selected = ((IStructuredSelection) layoutType.
                    getSelection()).getFirstElement();
            if (selected instanceof LayoutType) {
                type = (LayoutType) selected;
            }

            Layout layout = null;
            if (type == LayoutType.CANVAS) {
                layout = new CanvasLayout();
            } else if (type == LayoutType.MONTAGE) {
                layout = new MontageLayout(null);
            }

            if (type == null) {
                variant.setContentBuilder(null);
                variant.setVariantType(VariantType.NULL);
            } else {
                content.setLayout(layout);
                variant.setContentBuilder(content);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.policies.variants.VariantBuilder

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.