| Viewable.java |
1 /**
2 * Distribution License:
3 * JSword is free software; you can redistribute it and/or modify it under
4 * the terms of the GNU Lesser General Public License, version 2.1 as published by
5 * the Free Software Foundation. This program is distributed in the hope
6 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 * See the GNU Lesser General Public License for more details.
9 *
10 * The License is available on the internet at:
11 * http://www.gnu.org/copyleft/lgpl.html
12 * or by writing to:
13 * Free Software Foundation, Inc.
14 * 59 Temple Place - Suite 330
15 * Boston, MA 02111-1307, USA
16 *
17 * Copyright: 2005
18 * The copyright to this program is held by it's authors.
19 *
20 * ID: $Id: Viewable.java 2050 2010-12-09 15:31:45Z dmsmith $
21 */
22 package org.crosswire.common.swing.desktop;
23
24 import java.awt.Component;
25 import java.util.Collection;
26
27 import org.crosswire.common.swing.desktop.event.ViewEventListener;
28
29 /**
30 * Interface defining what is Viewable.
31 *
32 * @see gnu.lgpl.License for license details.<br>
33 * The copyright to this program is held by it's authors.
34 * @author DM Smith [ dmsmith555 at yahoo dot com]
35 */
36 public interface Viewable extends Iterable<Component> {
37 /**
38 * Add a view to the set.
39 */
40 void addView(Component component);
41
42 /**
43 * Remove a view from the set.
44 */
45 void removeView(Component component);
46
47 /**
48 * Get a snapshot of the views as a collection.
49 *
50 * @return the views
51 */
52 Collection<Component> getViews();
53
54 /**
55 * Copies all the views from the one layout to the other
56 *
57 * @param other
58 * the other layout
59 */
60 void moveTo(AbstractViewLayout other);
61
62 /**
63 * Close all the views. Note the policy is enforced that one view is kept.
64 * This will keep the last one added.
65 */
66 void closeAll();
67
68 /**
69 * Close all the views but the one provided.
70 *
71 * @param component
72 * the view that is to remain open.
73 */
74 void closeOthers(Component component);
75
76 /**
77 * Visit every view in the order that they were added.
78 *
79 * @param visitor
80 * The visitor for the view
81 */
82 void visit(ViewVisitor visitor);
83
84 /**
85 * Update the title of the view. If the component does not implement
86 * Titleable, then a generated title will be used.
87 *
88 * @param component
89 * the component whose title is to be used
90 */
91 void updateTitle(Component component);
92
93 /**
94 * Returns the top view. If no view is the top, it returns the first one
95 * added.
96 */
97 Component getSelected();
98
99 /**
100 * Find the view and select it.
101 *
102 * @param component
103 */
104 void select(Component component);
105
106 /**
107 * The number of views held by this layout.
108 *
109 * @return the number of views held by this layout
110 */
111 int getViewCount();
112
113 /**
114 * Get the view by position. Note that adding and removing views changes the
115 * indexes of the views. Do not use this for iteration as it is not thread
116 * safe.
117 *
118 * @param i
119 * the index of the view
120 * @return the requested view.
121 */
122 Component getView(int i);
123
124 /**
125 * Adds a view event listener for notification of any changes to the view.
126 *
127 * @param listener
128 * the listener
129 */
130 void addViewEventListener(ViewEventListener listener);
131
132 /**
133 * Removes a view event listener.
134 *
135 * @param listener
136 * the listener
137 */
138 void removeViewEventListener(ViewEventListener listener);
139 }
140