Package adams.flow.setup
Class FlowSetupManager
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<FlowSetup>
-
- adams.flow.setup.FlowSetupManager
-
- All Implemented Interfaces:
CloneHandler<FlowSetupManager>
,FlowSetupStateListener
,Serializable
,Cloneable
,Iterable<FlowSetup>
,Collection<FlowSetup>
,List<FlowSetup>
,RandomAccess
public class FlowSetupManager extends Vector<FlowSetup> implements FlowSetupStateListener, CloneHandler<FlowSetupManager>
Manages several setups.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
COUNT
the key for the number of stored setups.protected HashSet<ChangeListener>
m_ChangeListeners
the change listeners.protected boolean
m_Modified
whether manager got modified.protected StatusMessageHandler
m_StatusMessageHandler
the handler to use for displaying messages.static String
PLACEHOLDER_PREFIX
the key prefix for a placeholder.static String
SETUP_PREFIX
the key prefix for a setup.-
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description FlowSetupManager()
Initializes the setup manager.FlowSetupManager(Collection<FlowSetup> collection)
Initializes the setup manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, FlowSetup element)
Adds the setup at the specified location.boolean
add(FlowSetup e)
Adds a setup.boolean
addAll(int index, Collection<? extends FlowSetup> c)
Adds all elements of the collection at the specified location.boolean
addAll(Collection<? extends FlowSetup> c)
Adds all the setups from the collection.void
addChangeListener(ChangeListener l)
Adds the listener to the internal list.void
addElement(FlowSetup obj)
Adds the specified setup.void
clear()
Removes all setups.void
flowSetupStateChanged(FlowSetupStateEvent e)
Gets called when the state of the flow setup changed.FlowSetupManager
getClone()
Returns a clone of itself, with the setups being shallow copies.StatusMessageHandler
getStatusMessageHandler()
Returns the current handler for status messages.int
indexOf(String name)
Returns the index of the flowsetup with the given name.void
insertElementAt(FlowSetup obj, int index)
Inserts the setup at the specified location.boolean
isModified()
Returns whether the manager was modified.protected void
modified()
Sets the modified state to TRUE and notifies all change listeners.protected void
modified(boolean modified)
Sets the modified state and notifies all change listeners.protected void
notifyChangeListeners(ChangeEvent e)
Sends the event to all change listeners.boolean
read(String filename)
Reads and returns the setups from the given file.FlowSetup
remove(int index)
Removes the specified setup.boolean
remove(Object o)
Removes the specified object.boolean
removeAll(Collection<?> c)
Removes all setups of the specified collection.void
removeAllElements()
Removes all setups.void
removeChangeListener(ChangeListener l)
Removes the listener from the internal list.boolean
removeElement(Object obj)
Removes the specified setup.void
removeElementAt(int index)
Removes the setup at the specified location.protected void
removeRange(int fromIndex, int toIndex)
Removes a range of setups.boolean
retainAll(Collection<?> c)
Retains only setups that are in the specified collection.FlowSetup
set(int index, FlowSetup element)
Sets the setup at the specified location.void
setElementAt(FlowSetup obj, int index)
Sets the setup at the specified location.void
setModified(boolean value)
Sets the modified state of the manager.void
setSize(int newSize)
Resizes the collection: if new size is larger, then null objects are added, otherwise the setups at the end discarded.void
setStatusMessageHandler(StatusMessageHandler value)
Sets the handler for status messages.boolean
write(String filename)
Writes the setups to the given file.-
Methods inherited from class java.util.Vector
capacity, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, removeIf, replaceAll, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Field Detail
-
COUNT
public static final String COUNT
the key for the number of stored setups.- See Also:
- Constant Field Values
-
SETUP_PREFIX
public static final String SETUP_PREFIX
the key prefix for a setup.- See Also:
- Constant Field Values
-
PLACEHOLDER_PREFIX
public static final String PLACEHOLDER_PREFIX
the key prefix for a placeholder.- See Also:
- Constant Field Values
-
m_Modified
protected boolean m_Modified
whether manager got modified.
-
m_ChangeListeners
protected HashSet<ChangeListener> m_ChangeListeners
the change listeners.
-
m_StatusMessageHandler
protected StatusMessageHandler m_StatusMessageHandler
the handler to use for displaying messages.
-
-
Constructor Detail
-
FlowSetupManager
public FlowSetupManager()
Initializes the setup manager.
-
FlowSetupManager
public FlowSetupManager(Collection<FlowSetup> collection)
Initializes the setup manager.- Parameters:
collection
- the collection to initialize with
-
-
Method Detail
-
setStatusMessageHandler
public void setStatusMessageHandler(StatusMessageHandler value)
Sets the handler for status messages.- Parameters:
value
- the handler
-
getStatusMessageHandler
public StatusMessageHandler getStatusMessageHandler()
Returns the current handler for status messages.- Returns:
- the handler, null if none set
-
isModified
public boolean isModified()
Returns whether the manager was modified.- Returns:
- true if modified
-
setModified
public void setModified(boolean value)
Sets the modified state of the manager.- Parameters:
value
- the modified state
-
modified
protected void modified()
Sets the modified state to TRUE and notifies all change listeners.
-
modified
protected void modified(boolean modified)
Sets the modified state and notifies all change listeners.- Parameters:
modified
- the modified state
-
add
public boolean add(FlowSetup e)
Adds a setup.
-
addAll
public boolean addAll(Collection<? extends FlowSetup> c)
Adds all the setups from the collection.
-
addElement
public void addElement(FlowSetup obj)
Adds the specified setup.- Overrides:
addElement
in classVector<FlowSetup>
- Parameters:
obj
- the setup to add
-
add
public void add(int index, FlowSetup element)
Adds the setup at the specified location.
-
addAll
public boolean addAll(int index, Collection<? extends FlowSetup> c)
Adds all elements of the collection at the specified location.
-
clear
public void clear()
Removes all setups.
-
getClone
public FlowSetupManager getClone()
Returns a clone of itself, with the setups being shallow copies.- Specified by:
getClone
in interfaceCloneHandler<FlowSetupManager>
- Returns:
- the clone
-
insertElementAt
public void insertElementAt(FlowSetup obj, int index)
Inserts the setup at the specified location.- Overrides:
insertElementAt
in classVector<FlowSetup>
- Parameters:
obj
- the setup to insertindex
- the position
-
remove
public FlowSetup remove(int index)
Removes the specified setup.
-
removeAll
public boolean removeAll(Collection<?> c)
Removes all setups of the specified collection.
-
remove
public boolean remove(Object o)
Removes the specified object.
-
removeAllElements
public void removeAllElements()
Removes all setups.- Overrides:
removeAllElements
in classVector<FlowSetup>
-
removeElement
public boolean removeElement(Object obj)
Removes the specified setup.- Overrides:
removeElement
in classVector<FlowSetup>
- Parameters:
obj
- the setup to remove- Returns:
- true if removed successfully
-
removeElementAt
public void removeElementAt(int index)
Removes the setup at the specified location.- Overrides:
removeElementAt
in classVector<FlowSetup>
- Parameters:
index
- the position of the setup to remove
-
removeRange
protected void removeRange(int fromIndex, int toIndex)
Removes a range of setups.- Overrides:
removeRange
in classVector<FlowSetup>
- Parameters:
fromIndex
- starting index (incl)toIndex
- ending index (excl)
-
retainAll
public boolean retainAll(Collection<?> c)
Retains only setups that are in the specified collection.
-
setElementAt
public void setElementAt(FlowSetup obj, int index)
Sets the setup at the specified location.- Overrides:
setElementAt
in classVector<FlowSetup>
- Parameters:
obj
- the setup to setindex
- the position to place the setup
-
setSize
public void setSize(int newSize)
Resizes the collection: if new size is larger, then null objects are added, otherwise the setups at the end discarded.
-
write
public boolean write(String filename)
Writes the setups to the given file.- Parameters:
filename
- the file to write to- Returns:
- true if successfully written
-
read
public boolean read(String filename)
Reads and returns the setups from the given file.- Parameters:
filename
- the file to read from- Returns:
- true if successfully read
-
indexOf
public int indexOf(String name)
Returns the index of the flowsetup with the given name.- Parameters:
name
- the name to look for- Returns:
- the index, -1 if not found
-
flowSetupStateChanged
public void flowSetupStateChanged(FlowSetupStateEvent e)
Gets called when the state of the flow setup changed.- Specified by:
flowSetupStateChanged
in interfaceFlowSetupStateListener
- Parameters:
e
- the event
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds the listener to the internal list.- Parameters:
l
- the listener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes the listener from the internal list.- Parameters:
l
- the listener to remove
-
notifyChangeListeners
protected void notifyChangeListeners(ChangeEvent e)
Sends the event to all change listeners.- Parameters:
e
- the event to send
-
-