org.fife.rtext.StoreKeeper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rtext Show documentation
Show all versions of rtext Show documentation
RText is a powerful, cross-platform programmer's text editor written in Java. It is designed
to be easy to use, highly customizable and flexible. Part of RText's design is for the source code
to be simple, easy to understand, and well documented, so that other programmers can look into its
inner-workings and figure out how RText ticks with ease. A good place to start (besides the source
code) is the Javadoc for all classes used in the project.
/*
* 11/14/2003
*
* StoreKeeper.java - Keeps track of all RText instances (windows) that are
* open, and provides an interface to update their Look and Feels together.
* Copyright (C) 2003 Robert Futrell
* http://fifesoft.com/rtext
* Licensed under a modified BSD license.
* See the included license file for details.
*/
package org.fife.rtext;
import java.util.ArrayList;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
/**
* Keeps track of all org.fife.rtext.RText
instances (windows) that
* are open, and provides an interface to update their Look and Feels together.
*
* @author Robert Futrell
* @version 1.0
*/
public class StoreKeeper {
private static ArrayList rtextInstances;
/**
* Notes that a new RText
window is open.
*
* @param rtext The RText
instance to remember.
*/
public static void addRTextInstance(RText rtext) {
if (rtextInstances==null)
rtextInstances = new ArrayList(1);
rtextInstances.add(rtext);
}
/**
* Gets the number of RText
instances (windows) that are
* currently open.
*
* @return The number of RText
instances open.
*/
public static int getInstanceCount() {
return rtextInstances.size();
}
/**
* Removes an RText
instance.
*
* @param rtext The RText
to remove.
* @throws NullPointerException If no RText
instances have
* been remembered yet.
*/
public static void removeRTextInstance(RText rtext) {
int index = rtextInstances.indexOf(rtext);
if (index==-1)
//throw new RTextNotFoundException();
return;
rtextInstances.remove(index);
}
/**
* Updates the Look and Feel of all RText
instances.
*
* @param lnf The Look and Feel to change to.
*/
public static void updateLookAndFeels(final LookAndFeel lnf) {
Runnable updateUIRunnable = new Runnable() {
public void run() {
int count = getInstanceCount();
for (int i=0; i