Package com.bc.ceres.swing.selection
Class AbstractSelectionContext
- java.lang.Object
-
- com.bc.ceres.core.ExtensibleObject
-
- com.bc.ceres.swing.selection.AbstractSelectionContext
-
- All Implemented Interfaces:
Extensible
,SelectionChangeEmitter
,SelectionContext
,SelectionSource
- Direct Known Subclasses:
ComboBoxSelectionContext
,DefaultSelectionContext
,ListSelectionContext
,TableSelectionContext
,TreeSelectionContext
public abstract class AbstractSelectionContext extends ExtensibleObject implements SelectionContext
A handy base class for implementations of theSelectionContext
interface.Clients only need to implement the methods
SelectionSource.getSelection()
andSelectionContext.setSelection(Selection)
.No particular selection operations are implemented, e.g.
canDeleteSelection()
,canInsert(java.awt.datatransfer.Transferable)
,canSelectAll()
, all returnfalse
.- Since:
- Ceres 0.10
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSelectionContext()
protected
AbstractSelectionContext(Object selectionSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSelectionChangeListener(SelectionChangeListener listener)
Adds a selection change listener to this emitter.boolean
canDeleteSelection()
boolean
canInsert(Transferable contents)
Tests whether the current contents (e.g.boolean
canSelectAll()
void
deleteSelection()
Deletes the current selection.protected void
fireSelectionChange(Selection selection)
SelectionChangeListener[]
getSelectionChangeListeners()
Gets all registered selection change listeners.void
insert(Transferable transferable)
Inserts a selection represented by the givenTransferable
into this context.void
removeSelectionChangeListener(SelectionChangeListener listener)
Removes a selection change listener from this emitter.void
selectAll()
Selects all items.-
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.bc.ceres.core.Extensible
getExtension
-
Methods inherited from interface com.bc.ceres.swing.selection.SelectionContext
setSelection
-
Methods inherited from interface com.bc.ceres.swing.selection.SelectionSource
getSelection
-
-
-
-
Constructor Detail
-
AbstractSelectionContext
protected AbstractSelectionContext()
-
AbstractSelectionContext
protected AbstractSelectionContext(Object selectionSource)
-
-
Method Detail
-
canInsert
public boolean canInsert(Transferable contents)
Description copied from interface:SelectionContext
Tests whether the current contents (e.g. from clipboard, drag and drop) can be inserted into this selection context.- Specified by:
canInsert
in interfaceSelectionContext
- Parameters:
contents
- The contents.- Returns:
true
if the given contents can be inserted into this context.- See Also:
SelectionContext.insert(Transferable)
-
insert
public void insert(Transferable transferable) throws IOException, UnsupportedFlavorException
Description copied from interface:SelectionContext
Inserts a selection represented by the givenTransferable
into this context.- Specified by:
insert
in interfaceSelectionContext
- Parameters:
transferable
- The transferable object.- Throws:
IOException
- if an I/O error occursUnsupportedFlavorException
- See Also:
SelectionContext.canInsert(java.awt.datatransfer.Transferable)
,Selection.createTransferable(boolean)
,ClipboardOwner.lostOwnership(java.awt.datatransfer.Clipboard, java.awt.datatransfer.Transferable)
-
canDeleteSelection
public boolean canDeleteSelection()
- Specified by:
canDeleteSelection
in interfaceSelectionContext
- Returns:
true
if the current selection can be deleted.- See Also:
SelectionContext.deleteSelection()
-
deleteSelection
public void deleteSelection()
Description copied from interface:SelectionContext
Deletes the current selection.- Specified by:
deleteSelection
in interfaceSelectionContext
- See Also:
SelectionContext.canDeleteSelection()
-
canSelectAll
public boolean canSelectAll()
- Specified by:
canSelectAll
in interfaceSelectionContext
- Returns:
true
if all items can be selected.- See Also:
SelectionContext.selectAll()
-
selectAll
public void selectAll()
Description copied from interface:SelectionContext
Selects all items.- Specified by:
selectAll
in interfaceSelectionContext
- See Also:
SelectionContext.canSelectAll()
-
addSelectionChangeListener
public void addSelectionChangeListener(SelectionChangeListener listener)
Description copied from interface:SelectionChangeEmitter
Adds a selection change listener to this emitter.- Specified by:
addSelectionChangeListener
in interfaceSelectionChangeEmitter
- Parameters:
listener
- The listener.
-
removeSelectionChangeListener
public void removeSelectionChangeListener(SelectionChangeListener listener)
Description copied from interface:SelectionChangeEmitter
Removes a selection change listener from this emitter.- Specified by:
removeSelectionChangeListener
in interfaceSelectionChangeEmitter
- Parameters:
listener
- The listener.
-
getSelectionChangeListeners
public SelectionChangeListener[] getSelectionChangeListeners()
Description copied from interface:SelectionChangeEmitter
Gets all registered selection change listeners.- Specified by:
getSelectionChangeListeners
in interfaceSelectionChangeEmitter
- Returns:
- An array containing all registered listeners.
-
fireSelectionChange
protected void fireSelectionChange(Selection selection)
-
-