source: trunk/gsdl/src/phind/client/ResultDisplay.java@ 1636

Last change on this file since 1636 was 1627, checked in by paynter, 24 years ago

The applet is now operational. Phrases work, documents work, getting new
phrases and documents work, backdrops work.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/**********************************************************************
2 *
3 * ResultDisplay.java -- Phrase list holder for Phind java applet
4 *
5 * Copyright 1997-2000 Gordon W. Paynter
6 * Copyright 2000 The New Zealand Digital Library Project
7 *
8 * A component of the Greenstone digital library software
9 * from the New Zealand Digital Library Project at the
10 * University of Waikato, New Zealand.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 *********************************************************************/
27
28/*********************************************************************
29
30This class is used in the Phind java applet (Phind.java).
31
32A ResultDisplay is a Panel that can display a single Component, which will
33be a ResultBox or PhindTitle object.
34
35ResultBoxes can be "chained" together with their "prev" and "next" fields,
36allowing us to have an arbitrary number of "displays" in which to show
37phrase lists.
38
39Main methods:
40* emptyContents will remove the component and emptyAll the "next" display
41* display will add an item to the first (ie: most "prev") available box
42
43**********************************************************************/
44
45
46import java.awt.Panel;
47import java.awt.BorderLayout;
48import java.awt.Component;
49
50class ResultDisplay extends Panel {
51
52 Phind phind;
53 ResultDisplay prev, next;
54 Component current;
55 boolean empty;
56
57 // Create a new Display
58 ResultDisplay(Phind ph, ResultDisplay pr) {
59 phind = ph;
60 prev = pr;
61 next = null;
62 if (prev != null) prev.next = this;
63 setLayout(new BorderLayout());
64
65 empty = true;
66 current = new PhindTitle(ph);
67 add(current);
68 }
69
70 // Empty the contents of the display,
71 // and all the next displays
72 void emptyContents() {
73 if (empty == false) {
74 empty = true;
75 current = new PhindTitle(phind);
76 removeAll();
77 add(current);
78 }
79 if (next != null) next.emptyContents();
80 }
81
82 // Set the contents of this display
83 Component setContents( Component r ) {
84 removeAll();
85 add("Center", r);
86 current = r;
87 empty = false;
88 if (r.getClass().getName().equals("ResultBox")) {
89 ((ResultBox) r).display = this;
90 }
91 return r;
92 }
93
94
95
96 // Display a component in the "most previous" display
97 ResultDisplay display( Component r ) {
98
99 if (prev == null) {
100 // if there is no previous box, add the component here
101 setContents(r);
102 return this;
103
104 } else if (prev.empty == true) {
105 // if the previous box is empty, add the component to it instead
106 return prev.display(r);
107
108 } else if (empty == true) {
109 // if this box is empty, add the compnent to it
110 setContents(r);
111 return this;
112
113 } else {
114 // if this box is occupied,
115 // shift it's contents prev-wards and add here.
116 prev.display(current);
117 setContents(r);
118 return this;
119 }
120 }
121
122}
123
124
125
Note: See TracBrowser for help on using the repository browser.