Search in sources :

Example 1 with CustomAndExpression

use of org.eclipse.ui.internal.navigator.CustomAndExpression in project polymap4-core by Polymap4.

the class CommonSorterDescriptor method init.

private void init() {
    id = element.getAttribute(ATT_ID);
    if (id == null) {
        // $NON-NLS-1$
        id = "";
    }
    IConfigurationElement[] children = element.getChildren(TAG_PARENT_EXPRESSION);
    if (children.length == 1) {
        parentExpression = new CustomAndExpression(children[0]);
    }
}
Also used : CustomAndExpression(org.eclipse.ui.internal.navigator.CustomAndExpression) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 2 with CustomAndExpression

use of org.eclipse.ui.internal.navigator.CustomAndExpression in project polymap4-core by Polymap4.

the class CommonFilterDescriptor method init.

private void init() {
    id = element.getAttribute(ATT_ID);
    if (id == null) {
        // $NON-NLS-1$
        id = "";
    }
    IConfigurationElement[] children = element.getChildren(TAG_FILTER_EXPRESSION);
    if (children.length == 1) {
        filterExpression = new CustomAndExpression(children[0]);
    }
}
Also used : CustomAndExpression(org.eclipse.ui.internal.navigator.CustomAndExpression) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 3 with CustomAndExpression

use of org.eclipse.ui.internal.navigator.CustomAndExpression in project polymap4-core by Polymap4.

the class LinkHelperDescriptor method init.

void init() {
    id = configElement.getAttribute(ATT_ID);
    IConfigurationElement[] expressions = this.configElement.getChildren(EDITOR_INPUT_ENABLEMENT);
    Assert.isLegal(expressions.length == 1, // $NON-NLS-1$
    "The linkHelper extension point requires exactly one editorInputEnablement child.");
    editorInputEnablement = new CustomAndExpression(expressions[0]);
    expressions = configElement.getChildren(SELECTION_ENABLEMENT);
    if (expressions.length > 0) {
        // .getAttribute(ATT_NAVIGATOR_CONTENT_EXTENSION_ID);
        if (expressions[0].getChildren() != null && expressions[0].getChildren().length > 0) {
            selectionEnablement = new CustomAndExpression(expressions[0]);
        }
    }
}
Also used : CustomAndExpression(org.eclipse.ui.internal.navigator.CustomAndExpression) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 4 with CustomAndExpression

use of org.eclipse.ui.internal.navigator.CustomAndExpression in project polymap4-core by Polymap4.

the class NavigatorContentDescriptor method init.

/**
 * Parses the configuration element.
 *
 * @throws WorkbenchException
 *             if the configuration element could not be parsed. Reasons
 *             include:
 *             <ul>
 *             <li>A required attribute is missing.</li>
 *             <li>More elements are define than is allowed.</li>
 *             </ul>
 */
private void init() throws WorkbenchException {
    id = configElement.getAttribute(ATT_ID);
    name = configElement.getAttribute(ATT_NAME);
    String priorityString = configElement.getAttribute(ATT_PRIORITY);
    icon = configElement.getAttribute(ATT_ICON);
    String activeByDefaultString = configElement.getAttribute(ATT_ACTIVE_BY_DEFAULT);
    activeByDefault = (activeByDefaultString != null && activeByDefaultString.length() > 0) ? Boolean.valueOf(activeByDefaultString).booleanValue() : true;
    String providesSaveablesString = configElement.getAttribute(ATT_PROVIDES_SAVEABLES);
    providesSaveables = (providesSaveablesString != null && providesSaveablesString.length() > 0) ? Boolean.valueOf(providesSaveablesString).booleanValue() : false;
    appearsBeforeId = configElement.getAttribute(ATT_APPEARS_BEFORE);
    if (priorityString != null) {
        try {
            Priority p = Priority.get(priorityString);
            priority = p != null ? p.getValue() : Priority.NORMAL_PRIORITY_VALUE;
        } catch (NumberFormatException exception) {
            priority = Priority.NORMAL_PRIORITY_VALUE;
        }
    }
    // We start with this because the sort ExtensionPriorityComparator works
    // from the sequenceNumber
    sequenceNumber = priority;
    String sortOnlyString = configElement.getAttribute(ATT_SORT_ONLY);
    sortOnly = (sortOnlyString != null && sortOnlyString.length() > 0) ? Boolean.valueOf(sortOnlyString).booleanValue() : false;
    if (id == null) {
        throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { ATT_ID, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
    }
    contribution = new IPluginContribution() {

        public String getLocalId() {
            return getId();
        }

        public String getPluginId() {
            return configElement.getDeclaringExtension().getNamespaceIdentifier();
        }
    };
    IConfigurationElement[] children;
    children = configElement.getChildren(TAG_INITIAL_ACTIVATION);
    if (children.length > 0) {
        if (children.length == 1) {
            initialActivation = new CustomAndExpression(children[0]);
        } else {
            throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_INITIAL_ACTIVATION, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
        }
    }
    if (sortOnly)
        return;
    children = configElement.getChildren(TAG_ENABLEMENT);
    if (children.length == 0) {
        children = configElement.getChildren(TAG_TRIGGER_POINTS);
        if (children.length == 1) {
            enablement = new CustomAndExpression(children[0]);
        } else {
            throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_TRIGGER_POINTS, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
        }
        children = configElement.getChildren(TAG_POSSIBLE_CHILDREN);
        if (children.length == 1) {
            possibleChildren = new CustomAndExpression(children[0]);
        } else if (children.length > 1) {
            throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_POSSIBLE_CHILDREN, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
        }
    } else if (children.length == 1) {
        try {
            enablement = ElementHandler.getDefault().create(ExpressionConverter.getDefault(), children[0]);
        } catch (CoreException e) {
            NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
        }
    } else if (children.length > 1) {
        throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_ENABLEMENT, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
    }
    children = configElement.getChildren(TAG_OVERRIDE);
    if (children.length == 0) {
        overridePolicy = OverridePolicy.get(OverridePolicy.InvokeAlwaysRegardlessOfSuppressedExt_LITERAL);
    } else if (children.length == 1) {
        suppressedExtensionId = children[0].getAttribute(ATT_SUPPRESSED_EXT_ID);
        overridePolicy = OverridePolicy.get(children[0].getAttribute(ATT_POLICY));
    } else if (children.length > 1) {
        throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Too_many_elements_Warning, new Object[] { TAG_OVERRIDE, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
    }
}
Also used : CustomAndExpression(org.eclipse.ui.internal.navigator.CustomAndExpression) CoreException(org.eclipse.core.runtime.CoreException) Priority(org.eclipse.ui.navigator.Priority) IPluginContribution(org.eclipse.ui.IPluginContribution) WorkbenchException(org.eclipse.ui.WorkbenchException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 5 with CustomAndExpression

use of org.eclipse.ui.internal.navigator.CustomAndExpression in project polymap4-core by Polymap4.

the class CommonActionProviderDescriptor method init.

private void init() {
    try {
        definedId = configurationElement.getAttribute(ATT_ID);
        // if there was no id attribute, use the default id.
        if (definedId == null) {
            // $NON-NLS-1$
            definedId = DEFAULT_ID + "." + count++;
        }
        // we try the id attribute if no override id was supplied.
        if (visibilityId == null) {
            visibilityId = definedId;
        }
        dependsOnId = configurationElement.getAttribute(ATT_DEPENDS_ON);
        overridesId = configurationElement.getAttribute(ATT_OVERRIDES);
        appearsBeforeId = configurationElement.getAttribute(ATT_APPEARS_BEFORE);
        if (priority == null) {
            String prio = configurationElement.getAttribute(ATT_PRIORITY);
            if (prio != null)
                priority = Priority.get(prio);
            else
                priority = Priority.NORMAL;
        }
        IConfigurationElement[] children = configurationElement.getChildren(TAG_ENABLEMENT);
        // it
        if (children.length == 0 && enablementElement != null) {
            enablement = new CustomAndExpression(enablementElement);
        // otherwise the child enablement takes priority
        } else if (children.length == 1) {
            enablement = ElementHandler.getDefault().create(ExpressionConverter.getDefault(), children[0]);
        } else {
            System.err.println(// $NON-NLS-1$
            "Incorrect number of expressions: " + TAG_ENABLEMENT + // $NON-NLS-1$
            " in navigator extension: " + configurationElement.getDeclaringExtension().getUniqueIdentifier() + // $NON-NLS-1$
            " in plugin " + configurationElement.getDeclaringExtension().getNamespaceIdentifier());
        }
    } catch (CoreException e) {
        NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
    }
}
Also used : CustomAndExpression(org.eclipse.ui.internal.navigator.CustomAndExpression) CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)5 CustomAndExpression (org.eclipse.ui.internal.navigator.CustomAndExpression)5 CoreException (org.eclipse.core.runtime.CoreException)2 IPluginContribution (org.eclipse.ui.IPluginContribution)1 WorkbenchException (org.eclipse.ui.WorkbenchException)1 Priority (org.eclipse.ui.navigator.Priority)1