Package com.volantis.mcs.devices.policy.types

Examples of com.volantis.mcs.devices.policy.types.SelectionPolicyType


                IStructuredSelection selection =
                        (IStructuredSelection) combo.getSelection();
                String policyName = (String) selection.getFirstElement();
                PolicyDescriptor descriptor = (PolicyDescriptor)
                        namesToDescriptors.get(policyName);
                SelectionPolicyType policyType =
                        (SelectionPolicyType) descriptor.getPolicyType();
                context.setCategoryValues(policyType.getKeywords());

                BeanProxy model = (BeanProxy) context.getInteractionModel();
                Proxy categorisationScheme = model.getPropertyProxy(
                        PolicyModel.CATEGORISATION_SCHEME);

                if (!ObjectHelper.equals(policyName,
                        categorisationScheme.getModelObject())) {
                    Operation setSchemeOp = categorisationScheme
                            .prepareSetModelObjectOperation(policyName);
                    context.executeOperation(setSchemeOp);
                }
            }
        });

        BeanProxy model = (BeanProxy) context.getInteractionModel();
        final Proxy categorisationScheme =
                model.getPropertyProxy(PolicyModel.CATEGORISATION_SCHEME);
        String selectedPolicy = (String) categorisationScheme.getModelObject();
        if (selectedPolicy != null) {
            combo.setSelection(new StructuredSelection(selectedPolicy));
            PolicyDescriptor descriptor = (PolicyDescriptor)
                    namesToDescriptors.get(selectedPolicy);
            SelectionPolicyType policyType =
                    (SelectionPolicyType) descriptor.getPolicyType();
            context.setCategoryValues(policyType.getKeywords());
        }

        categorisationScheme.addListener(new InteractionEventListenerAdapter() {
            protected void interactionEvent(InteractionEvent event) {
                String selectedPolicy =
                        (String) categorisationScheme.getModelObject();
                if (selectedPolicy != null) {
                    combo.setSelection(new StructuredSelection(selectedPolicy));
                    PolicyDescriptor descriptor = (PolicyDescriptor)
                            namesToDescriptors.get(selectedPolicy);
                    SelectionPolicyType policyType =
                            (SelectionPolicyType) descriptor.getPolicyType();
                    context.setCategoryValues(policyType.getKeywords());
                }
            }
        }, false);
    }
View Full Code Here


     * @param namesToDescriptors
     * @param policies
     */
    private void addNullDescriptor(Map namesToDescriptors, List policies) {
        // Add a null descriptor which matches to nothing
        SelectionPolicyType selectionType = new SelectionPolicyType() {
            public List getKeywords() {
                return new ArrayList();
            }
        };
        final PolicyDescriptor nullDescriptor =
View Full Code Here

            assertEquals("SelectionPolicyDescName",
                policyDescriptor.getPolicyDescriptiveName());
            assertEquals("SelectionPolicyHelp", policyDescriptor.getPolicyHelp());
            assertEquals("en_GB_", policyDescriptor.getLanguage());

            SelectionPolicyType selectionType =
                    (SelectionPolicyType)policyType;
            assertEquals("Selections size should match", 2,
                    selectionType.getKeywords().size());
            assertEquals("Selections size should match",
                    "keyword1", selectionType.getKeywords().get(0));
            assertEquals("Selections size should match",
                    "keyword2", selectionType.getKeywords().get(1));

            // Test the retrieval of a policy descriptor from VMTYPES_RANGE
            id = populateWithRanges(id);
            policyDescriptor = accessor.retrievePolicyDescriptor(
                    connection, "RangesPolicy", locale);
View Full Code Here

        } else if (policyType instanceof RangePolicyType) {
            RangePolicyType range = (RangePolicyType) policyType;
            insertTypeInstanceRange(connection, typeInstanceId,
                    range.getMinInclusive(), range.getMaxInclusive());
        } else if (policyType instanceof SelectionPolicyType) {
            SelectionPolicyType selection = (SelectionPolicyType) policyType;
            insertTypeInstanceSelection(connection, typeInstanceId,
                    selection.getKeywords());
        }
    }
View Full Code Here

                        " on the device");
                assertEquals("Category should match (selection)",
                        descriptor.getCategoryName(),
                        "system");
                // Ensure the type is of the correct type (try a cast!)
                SelectionPolicyType selectionType =
                        (SelectionPolicyType) descriptor.getPolicyType();
                String[] expected = new String[]{"none", "CLDC-1.0", "CDC-1.0"};
                List keywords = selectionType.getKeywords();
                int size = keywords.size();
                for (int i = 0; i < size; i++) {
                    assertEquals("Keyword " + i + " should match",
                            (String) keywords.get(i),
                            expected[i]);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.devices.policy.types.SelectionPolicyType

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.