Package com.volantis.mcs.interaction

Examples of com.volantis.mcs.interaction.ListProxy


        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;
                }
            }

            if (!setSelection) {
View Full Code Here


                IStructuredSelection selection =
                        (IStructuredSelection) viewer.getSelection();

                Object[] selectedObjects = selection.toArray();
                BeanProxy theme = (BeanProxy) context.getInteractionModel();
                ListProxy variants = (ListProxy)
                        theme.getPropertyProxy(PolicyModel.VARIANTS);
                for (int i = 0; i < selectedObjects.length; i++) {
                    variants.removeItemProxy((Proxy) selectedObjects[i]);
                }
            }
        };
        deleteAction.setText(EditorMessages.getString(RESOURCE_PREFIX +
                "delete.action"));
View Full Code Here

                    if (contents != null && contents.length > 0) {
                        for (int i = 0; i < contents.length; i++) {
                            Object newAsset = contents[i];
                            if (newAsset instanceof VariantBuilder) {
                                BeanProxy theme = (BeanProxy) context.getInteractionModel();
                                ListProxy variants = (ListProxy)
                                        theme.getPropertyProxy(PolicyModel.VARIANTS);
                                // TODO better We should probably check that we have the right sort of variant (or at least a compatible one)
                                Operation addOperation = variants.prepareAddModelItemOperation(newAsset);
                                context.executeOperation(addOperation);
                            }
                        }
                    }
                } finally {
View Full Code Here

     */
    public Action createAddVariantAction(final EditorContext context) {
        Action addAction = new Action() {
            public void run() {
                BeanProxy theme = (BeanProxy) context.getInteractionModel();
                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);
            }
        };
        addAction.setText(EditorMessages.getString(RESOURCE_PREFIX +
                "add.action"));
View Full Code Here

     */
    public Action createNewVariantAction(final EditorContext context, final Control control) {
        Action newAction = new Action() {
            public void run() {
                BeanProxy interactionModel = (BeanProxy) context.getInteractionModel();
                ListProxy variantsModel = (ListProxy) interactionModel.getPropertyProxy(PolicyModel.VARIANTS);
                VariantType type = ((PolicyEditorContext) context).getDefaultVariantType();
                NewVariantWizard wizard = NewVariantWizard.createNewVariantWizard(type, variantsModel, context);
                wizard.init(null, null);
                // Instantiates the wizard container with the wizard and opens it
                WizardDialog dialog = new WizardDialog(control.getShell(), wizard);
View Full Code Here

    }

    // Javadoc inherited
    public Object[] getElements(Object proxy) {
        if (proxy instanceof ListProxy) {
            ListProxy listProxy = (ListProxy) proxy;
            Object[] values = new Object[listProxy.size()];
            for (int i = 0; i < values.length; i++) {
                Proxy itemProxy = listProxy.getItemProxy(i);
                values[i] =
                        returnModel ? itemProxy.getModelObject() : itemProxy;
                // Null values are not permitted, so we use a special value to
                // indicate null.
                if (values[i] == null) {
View Full Code Here

                            ruleProxy.getPropertyProxy(Rule.SELECTORS);
                    Object model = selectorsProxy.getModelObject();
                    returnValue = selectorListToText((List) model);
                } else if (i == COLUMN_ORDER) {
                    // Order
                    ListProxy rules = (ListProxy) getSelectedStyleSheetProxy().
                            getPropertyProxy(ThemeModel.RULES);
                    int index = rules.getItemProxyIndex(ruleProxy);
                    // Indices start at 0, but humans expect 1...
                    returnValue = String.valueOf(index + 1);
                }
                return returnValue;
            }

            public void addListener(ILabelProviderListener iLabelProviderListener) {
            }

            public void dispose() {
            }

            public boolean isLabelProperty(Object o, String s) {
                return true;
            }

            public void removeListener(ILabelProviderListener iLabelProviderListener) {
            }
        };
        ruleTable.setLabelProvider(labelProvider);

        CellEditor editors [] = new CellEditor[2];
        editors[0] = new TextCellEditor(table);

        ruleTable.setCellEditors(editors);
        ruleTable.setColumnProperties(new String[]{"selectors", "order"});
        ruleTable.setCellModifier(new ICellModifier() {
            public boolean canModify(Object o, String s) {
                return "selectors".equals(s);
            }

            public Object getValue(Object o, String s) {
                Object value = null;
                // Only selectors are modifiable, so ignore all other settings
                if ("selectors".equals(s)) {
                    List selectors = ruleProxyToSelectorList((BeanProxy) o);
                    value = selectorListToText(selectors);
                }
                return value;
            }

            public void modify(Object tableItem, String columnName, Object newValue) {
                if ("selectors".equals(columnName)) {
                    TableItem item = (TableItem) tableItem;
                    BeanProxy ruleProxy = (BeanProxy) item.getData();
                    String oldValue = labelProvider.getColumnText(ruleProxy, COLUMN_SELECTOR);
                    if (!oldValue.equals(newValue)) {
                        List parsed =
                                CSS_PARSER.parseSelectorGroup((String) newValue);
                        ListProxy selectorsProxy = (ListProxy) ruleProxy.getPropertyProxy(Rule.SELECTORS);
                        Operation setList = selectorsProxy.prepareSetModelObjectOperation(parsed);
                        context.executeOperation(setList);
                    }
                }
            }
        });
View Full Code Here

    }

    private void createActions() {
        addAction = new Action() {
            public void run() {
                ListProxy rules = (ListProxy) getSelectedStyleSheetProxy().
                        getPropertyProxy(ThemeModel.RULES);
                Operation addOp = rules.prepareCreateAndAddProxyItemOperation();
                context.executeOperation(addOp);
                refreshRuleTable();
            }
        };
        addAction.setText(EditorMessages.getString(
                RESOURCE_PREFIX + "addAction.text"));

        newAction = new Action() {
            public void run() {
                SelectorGroupWizard wizard = new SelectorGroupWizard(
                        getShell(),
                        context.getProject());
                wizard.open();
                SelectorGroup group = wizard.getSelectorGroup();

                if (group != null) {
                    ListProxy rules = (ListProxy) getSelectedStyleSheetProxy().
                            getPropertyProxy(ThemeModel.RULES);
                    Operation addOp = rules.prepareCreateAndAddProxyItemOperation();
                    context.executeOperation(addOp);
                    BeanProxy newRule = (BeanProxy) rules.getItemProxy(rules.size() - 1);
                    ListProxy selectors = (ListProxy) newRule.getPropertyProxy(Rule.SELECTORS);
                    Operation setOp = selectors.prepareSetModelObjectOperation(wizard.getSelectorGroup().getSelectors());
                    context.executeOperation(setOp);
                }
            }
        };
        newAction.setText(EditorMessages.getString(
                RESOURCE_PREFIX + "newAction.text"));

        deleteAction = new Action() {
            public void run() {
                ListProxy rules = (ListProxy) getSelectedStyleSheetProxy().
                        getPropertyProxy(ThemeModel.RULES);
                IStructuredSelection selection =
                        (IStructuredSelection) ruleTable.getSelection();
                if (!selection.isEmpty()) {
                    Proxy selected = (Proxy) selection.getFirstElement();
                    Operation delOp =
                            rules.prepareRemoveProxyItemOperation(selected);
                    context.executeOperation(delOp);
               
                    refreshRuleTable();
                }
            }
View Full Code Here

        }
        return text;
    }

    private List ruleProxyToSelectorList(BeanProxy rule) {
        ListProxy selectorsProxy =
                (ListProxy) rule.getPropertyProxy(Rule.SELECTORS);
        return (List) selectorsProxy.getModelObject();
    }
View Full Code Here

                });
                enableableControls.add(button);
            }

            // Initialise the fallback policies
            ListProxy alternatePolicies =
                    (ListProxy) ((BeanProxy) context.getInteractionModel()).
                            getPropertyProxy(PolicyModel.ALTERNATE_POLICIES);
            int size = alternatePolicies.size();

            for (int i = 0; i < size; i++) {
                Proxy itemProxy = alternatePolicies.getItemProxy(i);
                Object modelObject = itemProxy.getModelObject();
                PolicyReference ref = (PolicyReference) modelObject;
                Text text = (Text) typesToTextComponents
                        .get(ref.getExpectedPolicyType());
                text.setText(ref.getName());
View Full Code Here

TOP

Related Classes of com.volantis.mcs.interaction.ListProxy

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.