Package com.volantis.mcs.eclipse.ab.actions

Examples of com.volantis.mcs.eclipse.ab.actions.ODOMActionCommand


    /**
     * Create the actions.
     */
    private void createActions() {
        // New policy
        ODOMActionCommand command = new ODOMActionCommand() {
            public boolean enable(ODOMActionDetails details) {
                Element selectedCategory = categoriesComposite.
                        getSelectedCategoryElement();
                boolean enabled = selectedCategory != null;
                if (enabled) {
                    // New policy is always enabled in admin mode when there
                    // is a selection.
                    enabled = context.isAdminProject();
                    if (!enabled) {
                        String categoryName = selectedCategory.
                                getAttributeValue(DeviceRepositorySchemaConstants.
                                CATEGORY_NAME_ATTRIBUTE);
                        enabled = categoryName.equals(
                                DeviceRepositorySchemaConstants.CUSTOM_CATEGORY_NAME);
                    }
                }
                return enabled;
            }

            public void run(ODOMActionDetails details) {
                NewDevicePolicyWizard wizard =
                        new NewDevicePolicyWizard(getShell(),
                                context.getDeviceRepositoryAccessorManager());
                wizard.open();
                String policyName = wizard.getPolicyName();
                // If the custom category is selected then prefix the policy
                // name with the custom prefix to enable it to be identified
                // as a custom policy.
                if (categoriesComposite.
                        getSelectedCategoryElement().
                        getAttributeValue(DeviceRepositorySchemaConstants.
                        CATEGORY_NAME_ATTRIBUTE).
                        equals(DeviceRepositorySchemaConstants.
                        CUSTOM_CATEGORY_NAME)) {
                    StringBuffer buffer =
                            new StringBuffer(EclipseDeviceRepository.
                            getCustomPolicyNamePrefix());
                    buffer.append(policyName);
                    policyName = buffer.toString();
                }
                PolicyTypeComposition composition =
                        wizard.getPolicyTypeComposition();
                PolicyType type = wizard.getPolicyType();
                if (policyName != null && composition != null && type != null) {
                    // we don't allow policy creation to
                    // be undoable
                    try {
                        context.getUndoRedoManager().enable(false);
                        addNewPolicyToRepository(policyName, composition, type);
                    } finally {
                        context.getUndoRedoManager().enable(true);
                    }
                    selectNewPolicy(policyName);
                }
            }
        };

        newPolicyAction = new ODOMAction(command,
                context,
                null,
                DevicesMessages.getResourceBundle(),
                RESOURCE_PREFIX + "newPolicy.");

        // Delete policy
        command = new ODOMActionCommand() {
            public boolean enable(ODOMActionDetails details) {
                boolean enabled = categoriesComposite.getSelectedPolicyElement()
                        != null;

                if (enabled) {
View Full Code Here


                doTestEnable(data, "test cut enable", true);
                // perform the cut operation
                doTestRun(data, SINGLE_PANE_DELETED_RUN);

                // now perform a paste using the previously cut element
                ODOMActionCommand command = new PasteActionCommand(clipboard,
                        context);
                data = createTestData(command);
                setDocument(data, context.getRootElement());
                setSelectionManager(data, context.getODOMSelectionManager());
                setSelections(data, new String[]{EMPTY_ELEMENT_PATH});
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.ab.actions.ODOMActionCommand

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.