All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fife.ui.rsyntaxtextarea.folding.FoldCollapser Maven / Gradle / Ivy

The newest version!
/*
 * 10/23/2011
 *
 * FoldCollapser.java - Goes through an RSTA instance and collapses folds of
 * specific types, such as comments.
 * 
 * This library is distributed under a modified BSD license.  See the included
 * RSyntaxTextArea.License.txt file for details.
 */
package org.fife.ui.rsyntaxtextarea.folding;

import java.util.ArrayList;
import java.util.List;


/**
 * Collapses folds based on their type.  You can create an instance of this
 * class to collapse all comment blocks when opening a new file, for example.
 *
 * @author Robert Futrell
 * @version 1.0
 */
public class FoldCollapser {

	private List typesToCollapse;


	/**
	 * Creates an instance that collapses all comment blocks.
	 */
	public FoldCollapser() {
		this(FoldType.COMMENT);
	}


	/**
	 * Creates an instance that collapses all blocks of the specified
	 * type.
	 *
	 * @param typeToCollapse The type to collapse.
	 * @see FoldType
	 */
	public FoldCollapser(int typeToCollapse) {
		typesToCollapse = new ArrayList(3);
		addTypeToCollapse(typeToCollapse);
	}


	/**
	 * Adds a type of fold to collapse.
	 *
	 * @param typeToCollapse The type of fold to collapse.
	 */
	public void addTypeToCollapse(int typeToCollapse) {
		typesToCollapse.add(Integer.valueOf(typeToCollapse));
	}


	/**
	 * Collapses any relevant folds known by the fold manager.
	 *
	 * @param fm The fold manager.
	 */
	public void collapseFolds(FoldManager fm) {
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy