public abstract class AbstractViewLayout extends Object implements Viewable
The GNU General Public License for details.
Modifier and Type | Field and Description |
---|---|
private static int |
base
A shared counter for creating unknown titles.
|
private EventListenerList |
listenerList
The listeners for handling ViewEvent Listeners
|
private static int |
MAX_TITLE_LEN
The maximum length of a title before it is abbreviated
|
private JPanel |
panel
The panel into which all components are placed.
|
private List<Component> |
views
The list of views.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractViewLayout()
This constructor is protected because it only needs to be seen by the sub
classes
|
Modifier and Type | Method and Description |
---|---|
void |
addView(Component component)
Add a view to the set.
|
void |
addViewEventListener(ViewEventListener listener)
Adds a view event listener for notification of any changes to the view.
|
void |
closeAll()
Close all the views.
|
void |
closeOthers(Component component)
Close all the views but the one provided.
|
void |
fireViewRemoved(ViewEvent e)
Notify the listeners that the view has been removed.
|
protected void |
forceRemoveView(Component component)
Unconditionally remove a view from the set.
|
private String |
generateTitle()
Generates a generic title
|
protected Object |
getConstraint()
A constraint that allows the panel to be filled up, stretching
horizontally and vertically.
|
protected JPanel |
getPanel()
All parts are put into a panel.
|
abstract Component |
getSelected()
Returns the top view.
|
protected String |
getTitle(Component component)
Get the title from the component, truncating it if necessary.
|
Component |
getView(int i)
Get the view by position.
|
int |
getViewCount()
The number of views held by this layout.
|
Collection<Component> |
getViews()
Get a snapshot of the views as a collection.
|
Iterator<Component> |
iterator()
Get an iterator of a snapshot of views.
|
void |
moveTo(AbstractViewLayout other)
Copies all the views from the one layout to the other
|
void |
removeView(Component component)
Remove a view from the set.
|
void |
removeViewEventListener(ViewEventListener listener)
Removes a view event listener.
|
abstract void |
select(Component component)
Find the view and select it.
|
abstract void |
updateTitle(Component component)
Update the title of the view.
|
void |
visit(ViewVisitor visitor)
Visit every view in the order that they were added.
|
private EventListenerList listenerList
private static final int MAX_TITLE_LEN
private static int base
private JPanel panel
protected AbstractViewLayout()
public void addView(Component component)
public void removeView(Component component)
removeView
in interface Viewable
protected void forceRemoveView(Component component)
public Collection<Component> getViews()
public void moveTo(AbstractViewLayout other)
public void closeAll()
public void closeOthers(Component component)
closeOthers
in interface Viewable
component
- the view that is to remain open.public void visit(ViewVisitor visitor)
public abstract void updateTitle(Component component)
updateTitle
in interface Viewable
component
- the component whose title is to be usedpublic abstract Component getSelected()
getSelected
in interface Viewable
public abstract void select(Component component)
public int getViewCount()
getViewCount
in interface Viewable
public Component getView(int i)
protected String getTitle(Component component)
component
- from whom the title is gottenprivate String generateTitle()
protected JPanel getPanel()
protected Object getConstraint()
public void addViewEventListener(ViewEventListener listener)
addViewEventListener
in interface Viewable
listener
- the listenerpublic void removeViewEventListener(ViewEventListener listener)
removeViewEventListener
in interface Viewable
listener
- the listenerpublic void fireViewRemoved(ViewEvent e)
e
- the eventEventListenerList