org.eclipse.core.expressions.PropertyTester Java Examples

The following examples show how to use org.eclipse.core.expressions.PropertyTester. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PythonSourceFolderActionFilter.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds a way to check for the app_engine (currently hardcoded) property from this plugin.
 */
@Override
public boolean testAttribute(Object target, String name, String value) {
    //For now let's leave it checking only app_engine, but this could grow if needed.
    if ("app_engine".equals(name)) {
        List<PropertyTester> propertyTesters = getPropertyTestersFromPydevCustomizations(name);
        for (PropertyTester tester : propertyTesters) {
            if (tester.test(target, name, null, value)) {
                return true;
            }
        }
    }

    //If we didn't find what we were looking for, use the platform action filter
    if (this.platformActionFilter != null) {
        return this.platformActionFilter.testAttribute(target, name, value);
    }

    //if the platform didn't provide it, just return false.
    return false;
}
 
Example #2
Source File: PythonSourceFolderActionFilter.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Cache them after the 1st request for a given name.
 * 
 * Gets the property testers in org.python.pydev.customizations that match the passed name.
 */
private static synchronized List<PropertyTester> getPropertyTestersFromPydevCustomizations(String name) {
    List<PropertyTester> propertyTester = propertyTesters.get(name);
    if (propertyTester == null) {
        IExtension[] extensions = ExtensionHelper.getExtensions("org.eclipse.core.expressions.propertyTesters");
        // For each extension ...
        propertyTester = new ArrayList<PropertyTester>();
        propertyTesters.put(name, propertyTester);
        for (int i = 0; i < extensions.length; i++) {
            IExtension extension = extensions[i];
            IConfigurationElement[] elements = extension.getConfigurationElements();
            // For each member of the extension ...
            for (int j = 0; j < elements.length; j++) {
                IConfigurationElement element = elements[j];
                //Any property tester that's declared in "org.python.pydev.customizations"
                //is considered to be an object that provides the objectState for an IActionFilter.
                if ("org.python.pydev.customizations".equals(element.getAttribute("namespace"))) {
                    String attribute = element.getAttribute("properties");
                    if (name.equals(attribute)) {//i.e.: app_engine (and future references)
                        try {
                            PropertyTester executableExtension = (PropertyTester) element
                                    .createExecutableExtension("class");
                            propertyTester.add(executableExtension);
                        } catch (Exception e) {
                            Log.log(e);
                        }
                    }
                }
            }
        }
    }
    return propertyTester;
}