source: trunk/gli/src/org/greenstone/gatherer/gui/FormatPane.java@ 14038

Last change on this file since 14038 was 13709, checked in by mdewsnip, 17 years ago

Added some space above the "Preview Collection" button.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37package org.greenstone.gatherer.gui;
38
39import java.awt.*;
40import java.awt.event.*;
41import javax.swing.*;
42
43import org.greenstone.gatherer.Dictionary;
44import org.greenstone.gatherer.Gatherer;
45import org.greenstone.gatherer.cdm.CollectionDesignManager;
46import org.greenstone.gatherer.cdm.FormatManager;
47import org.greenstone.gatherer.cdm.Format;
48import org.greenstone.gatherer.cdm.Control;
49import org.greenstone.gatherer.Configuration;
50import org.greenstone.gatherer.shell.GShell;
51import org.greenstone.gatherer.shell.GShellEvent;
52import org.greenstone.gatherer.shell.GShellListener;
53
54public class FormatPane
55 extends BaseConfigPane
56 implements PreviewButtonOwner,GShellListener{
57
58
59 /** The button for viewing the collection. */
60 private PreviewButton preview_button = null;
61 private boolean buildCanceled = false;
62
63 /** The constructor. */
64 public FormatPane() {
65 super();
66 if (Gatherer.GS3) {
67 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation" };
68 } else {
69 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros" };
70 }
71 JPanel side_panel = new JPanel();
72 side_panel.setLayout(new BorderLayout());
73 remove(tree_pane);
74 side_panel.add(tree_pane, BorderLayout.CENTER);
75 JPanel preview_pane = new JPanel();
76 preview_pane.setLayout(new BorderLayout());
77 preview_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
78
79 preview_button = new PreviewButton(Dictionary.get("CreatePane.Preview_Collection"), Dictionary.get("CreatePane.Preview_Collection_Tooltip"));
80 preview_button.setEnabled(true);
81 preview_button.setVariablePreview(true);
82 preview_button.setOwner(this);
83 preview_pane.add(preview_button, BorderLayout.CENTER);
84
85
86 preview_button.addActionListener(new ActionListener() {
87 public void actionPerformed(ActionEvent event) {
88 if (view != null) {
89 view.loseFocus();
90 }
91
92 if (buildCanceled){
93 WarningDialog dialog = new WarningDialog("warning.ShowPreviousCollection", Dictionary.get("ShowPreviousCollection.Title"), Dictionary.get("ShowPreviousCollection.Message"), null, false);
94 dialog.display();
95 dialog.dispose();
96 }
97 }
98
99 });
100 side_panel.add(preview_pane, BorderLayout.SOUTH);
101
102 add(side_panel, BorderLayout.WEST);
103 }
104
105 public void gainFocus(){
106
107 if (Gatherer.c_man.built() && Configuration.library_url != null) {
108 preview_button.setEnabled(true);
109 }
110 else{
111 preview_button.setEnabled(false);
112 }
113
114 }
115
116
117 /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
118 * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
119 */
120 public synchronized void message(GShellEvent event) {
121 // We don't care.
122 }
123
124
125 /** All implementation of GShellListener must include this method so the listener can be informed when a GShell begins its task. Implementation side-effect, not actually used.
126 * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
127 */
128 public synchronized void processBegun(GShellEvent event) {
129 buildCanceled = false;
130 }
131
132 /** All implementation of GShellListener must include this method so the listener can be informed when a GShell completes its task.
133 * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
134 */
135 public synchronized void processComplete(GShellEvent event) {
136 if(event.getStatus() == GShell.OK) {
137 if(event.getType() == GShell.BUILD) {
138 buildCanceled = false;
139 }
140 }
141 else {
142 buildCanceled = true;
143 }
144 }
145
146
147
148 protected Control getSubControls(String type) {
149 if(type.equals("CDM.GUI.General")) {
150 return CollectionDesignManager.general_manager.getControls();
151 }
152 if (type.equals("CDM.GUI.SearchMetadata")) {
153 return CollectionDesignManager.searchmetadata_manager.getControls();
154 }
155 if(type.equals("CDM.GUI.Formats")) {
156 return CollectionDesignManager.format_manager.getControls();
157 }
158 if (type.equals("CDM.GUI.Translation")) {
159 return CollectionDesignManager.translation_manager.getControls();
160 }
161 if (type.equals("CDM.GUI.Macros")) {
162 return CollectionDesignManager.macros_manager.getControls();
163 }
164 if(type.equals("CDM.GUI.SuperCollection")) {
165 return CollectionDesignManager.supercollection_manager.getControls();
166 }
167 return null;
168 }
169
170 private int page_type = PreviewButton.HOME_PAGE;
171 private String page_params = "";
172 public int getPageType() {
173 System.err.println("view type = "+view_type);
174 if (view_type.equals("CDM.GUI.General") || view_type.equals("CDM.GUI.Translation")) {
175 page_type = PreviewButton.HOME_PAGE;
176 } else {
177 Format current_format = ((FormatManager.FormatControl)view).getCurrentFormat();
178 String feature_name = current_format.getFeatureName();
179 System.err.println("current format = "+feature_name);
180 if (feature_name.equals("")) {
181 // must be modifying VList or HList
182 // what should we do???
183 page_type = PreviewButton.CLASSIFIER_PAGE;
184 page_params = "CL1";
185 }
186 if (feature_name.startsWith("CL")) {
187 page_type = PreviewButton.CLASSIFIER_PAGE;
188 page_params = current_format.getFeatureName();
189 }
190 else if (feature_name.startsWith("Document")) {
191 page_type = PreviewButton.DOCUMENT_PAGE;
192 page_params = "HASH01e4da6100fdbb11b7ef244b";
193 }
194 else if (feature_name.equals("Search")) {
195 page_type = PreviewButton.SEARCH_PAGE;
196 page_params = "the";
197 }
198 }
199 return page_type;
200 }
201
202 public String getPageParams() {
203 return page_params;
204 }
205
206}
Note: See TracBrowser for help on using the repository browser.