Package org.gjt.sp.jedit.gui
Class HistoryModel
- java.lang.Object
-
- javax.swing.AbstractListModel<E>
-
- javax.swing.DefaultListModel<java.lang.String>
-
- org.gjt.sp.jedit.gui.HistoryModel
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.ListModel<java.lang.String>
,MutableListModel<java.lang.String>
public class HistoryModel extends javax.swing.DefaultListModel<java.lang.String> implements MutableListModel<java.lang.String>
A named history list One history list can be used by several history text fields. Note that the list model implementation is incomplete; no events are fired when the history model changes. The max size of the history is defined globally via setDefaultMax(), see jEdit.java for instance. It may be locally overriden by calling setMax() on a HistoryModel instance.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HistoryModel(java.lang.String name)
Creates a new history list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(java.lang.String text)
Adds an item to the end of this history list, trimming the list to the maximum number of items if necessary.static int
getDefaultMax()
Gets the default size of all HistoryModels.static int
getDefaultMaxSize()
Gets the default maximum size (in characters) for all history models.java.lang.String
getItem(int index)
Returns an item from the history list.int
getMax()
int
getMaxSize()
static HistoryModel
getModel(java.lang.String name)
Returns a named model.java.lang.String
getName()
Returns the name of this history list.void
insertElementAt(java.lang.String obj, int index)
static void
loadHistory()
void
removeAllElements()
boolean
removeElement(java.lang.Object obj)
static void
saveHistory()
static void
setDefaultMax(int max)
Sets the default size of all HistoryModels.static void
setDefaultMaxSize(int newMax)
Sets the default max size (in characters) for all history models.void
setMax(int max)
sets the maximum size of this historyvoid
setMaxSize(int max)
Sets the maximum size (in characters) for this history modelstatic void
setSaver(HistoryModelSaver saver)
-
Methods inherited from class javax.swing.DefaultListModel
add, addAll, addAll, addElement, capacity, clear, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, getSize, indexOf, indexOf, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeElementAt, removeRange, set, setElementAt, setSize, size, toArray, toString, trimToSize
-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Method Detail
-
addItem
public void addItem(java.lang.String text)
Adds an item to the end of this history list, trimming the list to the maximum number of items if necessary.- Parameters:
text
- The item
-
insertElementAt
public void insertElementAt(java.lang.String obj, int index)
- Specified by:
insertElementAt
in interfaceMutableListModel<java.lang.String>
- Overrides:
insertElementAt
in classjavax.swing.DefaultListModel<java.lang.String>
-
getItem
public java.lang.String getItem(int index)
Returns an item from the history list.- Parameters:
index
- The index
-
removeElement
public boolean removeElement(java.lang.Object obj)
- Specified by:
removeElement
in interfaceMutableListModel<java.lang.String>
- Overrides:
removeElement
in classjavax.swing.DefaultListModel<java.lang.String>
-
removeAllElements
public void removeAllElements()
- Overrides:
removeAllElements
in classjavax.swing.DefaultListModel<java.lang.String>
-
getName
public java.lang.String getName()
Returns the name of this history list. This can be passed to the HistoryTextField constructor.
-
getModel
public static HistoryModel getModel(java.lang.String name)
Returns a named model. If the specified model does not already exist, it will be created.- Parameters:
name
- The model name
-
loadHistory
public static void loadHistory()
-
saveHistory
public static void saveHistory()
-
setMax
public void setMax(int max)
sets the maximum size of this history- Parameters:
max
- the new maximum size of this history of -1 to restore default
-
getMax
public int getMax()
- Returns:
- maximum size of this history or -1 is it's the default size
-
setMaxSize
public void setMaxSize(int max)
Sets the maximum size (in characters) for this history model- Parameters:
max
- the new maximum size for the history model, or -1 to restore the default- Since:
- jEdit 4.5pre1
-
getMaxSize
public int getMaxSize()
- Returns:
- the maximum size (in characters) for this history model, or -1 for the default
- Since:
- jEdit 4.5pre1
-
setDefaultMax
public static void setDefaultMax(int max)
Sets the default size of all HistoryModels. Affects the VFS path history, the hypersearch history, etc.. To change the max size of one history, call setMax() instead.
-
getDefaultMax
public static int getDefaultMax()
Gets the default size of all HistoryModels.- Returns:
- default size limit for HistoryModels
-
setDefaultMaxSize
public static void setDefaultMaxSize(int newMax)
Sets the default max size (in characters) for all history models. To change the max size of one history, callsetMaxSize(int)
instead.- Since:
- jEdit 4.5pre1
-
getDefaultMaxSize
public static int getDefaultMaxSize()
Gets the default maximum size (in characters) for all history models.- Since:
- jEdit 4.5pre1
-
setSaver
public static void setSaver(HistoryModelSaver saver)
-
-