How to create a filter extension - JorgeBranquinho/outline GitHub Wiki

How to create a new filter

To create a new filter, it is necessary to implement the filter interface, named "OutlineFilter". The class implementing such interface will be composed by at least 3 methods: showMethodFilter, showFieldFilter, showClassFilter.

All 3 methods will later return a Boolean result: true if the corresponding method/class/filter is to be shown on the outline or false otherwise. Whoever implements the methods gets to decide which of the objects appear in the outline. Each of the methods, receive the corresponding object, that is, OutlineMethod, OutlineField and OutlineClass, respectively.

The example bellow will clarify some aspects of how this works:


public class Example implements OutlineFilter{
	@Override
	public boolean showMethodFilter(OutlineMethod om) {
		if(om.isConstructor())
			return false;
		return true;
	}

	@Override
	public boolean showFieldFilter(OutlineField of) {
		if(of.isStatic())
			return false;
		return false;
	}

	@Override
	public boolean showClassFilter(OutlineClass oc) {
		return true;
	}
}

In this class, named “Example”, the first method implemented is “showMethodFilter”. In this example, the goal is to show every method in the outline, except for the constructor(s). For that purpose if the argument returns true on the condition “om.isConstructor()”, then the method returns false (such method won’t appear in the outline), and true otherwise.

The second method has a similar behaviour checking if the field is static, displaying non-static only. The last method returns true, displaying all the classes in the outline. Note: all fields and methods are contained in a class, if that class is a nested class and the outline is defined to show such class, than the outer class will inherit all its methods and fields. If the class as no outer class, that is if it’s not nested type, than the name of the class by will surrounded by parenthesis, as shown in the example bellow:

The name field in the extension will be the name for the filter:

During the execution the filter can be turned on or off by selecting a check box on the bottom of the outline. There will be a named checkbox for each filter, followed by its name

⚠️ **GitHub.com Fallback** ⚠️