pypropertytester.java
来自「Python Development Environment (Python I」· Java 代码 · 共 40 行
JAVA
40 行
package org.python.pydev.navigator.properties;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IResource;
import org.python.pydev.navigator.elements.IWrappedResource;
import org.python.pydev.navigator.elements.PythonNode;
public class PyPropertyTester extends PropertyTester{
/**
* Converts the given expected value to a <code>String</code>.
*
* @param expectedValue
* the expected value (may be <code>null</code>).
* @return the empty string if the expected value is <code>null</code>,
* otherwise the <code>toString()</code> representation of the
* expected value
*/
protected String toString(Object expectedValue) {
return expectedValue == null ? "" : expectedValue.toString(); //$NON-NLS-1$
}
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if(receiver instanceof IWrappedResource){
if(receiver instanceof PythonNode){
return false;//do not filter python nodes.
}
IWrappedResource resource = (IWrappedResource) receiver;
IResource res = (IResource) resource.getAdapter(IResource.class);
if(res != null){
if (property.equals("name")) {
return new StringMatcherSimple(toString(expectedValue)).match(res.getName());
}
}
}
return false;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?