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

Last change on this file since 16680 was 16680, checked in by anna, 16 years ago

Improved customization of metadata sets/elements used in the Depositor. Two aspects involved: the front-end user interface (depositoraction.cpp) and back-end GLI format panel. Associated changes include the depositor's macro file, GLI dictionary and GLI help document

  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 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.Format4gs3Manager;
49import org.greenstone.gatherer.cdm.Format4gs3;
50import org.greenstone.gatherer.cdm.DOMProxyListEntry;
51import org.greenstone.gatherer.cdm.Control;
52import org.greenstone.gatherer.Configuration;
53import org.greenstone.gatherer.shell.GShell;
54import org.greenstone.gatherer.shell.GShellEvent;
55import org.greenstone.gatherer.shell.GShellListener;
56
57public class FormatPane
58extends BaseConfigPane
59implements PreviewButtonOwner,GShellListener{
60
61
62 /** The button for viewing the collection. */
63 private static PreviewButton preview_button = null;
64 private boolean buildCanceled = false;
65
66 /** The constructor. */
67 public FormatPane () {
68 super ();
69 if (Gatherer.GS3) {
70 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation" };
71 } else {
72 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros", "CDM.GUI.DepositorMetadata" };
73 }
74 JPanel side_panel = new JPanel ();
75 side_panel.setLayout (new BorderLayout ());
76 remove (tree_pane);
77 side_panel.add (tree_pane, BorderLayout.CENTER);
78 JPanel preview_pane = new JPanel ();
79 preview_pane.setLayout (new BorderLayout ());
80 preview_pane.setBorder (BorderFactory.createEmptyBorder (5,0,0,0));
81
82 preview_button = new PreviewButton (Dictionary.get ("CreatePane.Preview_Collection"), Dictionary.get ("CreatePane.Preview_Collection_Tooltip"));
83 preview_button.setEnabled (true);
84 preview_button.setVariablePreview (true);
85 preview_button.setOwner (this);
86 preview_pane.add (preview_button, BorderLayout.CENTER);
87
88
89 preview_button.addActionListener (new ActionListener () {
90 public void actionPerformed (ActionEvent event) {
91 if (view != null) {
92 view.loseFocus ();
93 }
94
95 if (buildCanceled){
96 WarningDialog dialog = new WarningDialog ("warning.ShowPreviousCollection", Dictionary.get ("ShowPreviousCollection.Title"), Dictionary.get ("ShowPreviousCollection.Message"), null, false);
97 dialog.display ();
98 dialog.dispose ();
99 }
100 }
101
102 });
103 side_panel.add (preview_pane, BorderLayout.SOUTH);
104
105 add (side_panel, BorderLayout.WEST);
106 }
107
108 public void gainFocus (){
109
110 if (Gatherer.c_man.built () && Configuration.library_url != null) {
111 preview_button.setEnabled (true);
112 }
113 else{
114 preview_button.setEnabled (false);
115 }
116
117 }
118 public static void setPreviewButton (boolean ready_to_preview) {
119 preview_button.setEnabled (ready_to_preview);
120 }
121
122 /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
123 * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
124 */
125 public synchronized void message (GShellEvent event) {
126 // We don't care.
127 }
128
129
130 /** 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.
131 * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
132 */
133 public synchronized void processBegun (GShellEvent event) {
134 buildCanceled = false;
135 }
136
137 /** All implementation of GShellListener must include this method so the listener can be informed when a GShell completes its task.
138 * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
139 */
140 public synchronized void processComplete (GShellEvent event) {
141 if(event.getStatus () == GShell.OK) {
142 if(event.getType () == GShell.BUILD) {
143 buildCanceled = false;
144 }
145 }
146 else {
147 buildCanceled = true;
148 }
149 }
150
151
152
153 protected Control getSubControls (String type) {
154 if(type.equals ("CDM.GUI.General")) {
155 return CollectionDesignManager.general_manager.getControls ();
156 }
157 if (type.equals ("CDM.GUI.SearchMetadata")) {
158 return CollectionDesignManager.searchmetadata_manager.getControls ();
159 }
160 if(type.equals ("CDM.GUI.Formats")) {
161 return CollectionDesignManager.format_manager.getControls ();
162 }
163 if (type.equals ("CDM.GUI.Translation")) {
164 return CollectionDesignManager.translation_manager.getControls ();
165 }
166 if (type.equals ("CDM.GUI.Macros")) {
167 return CollectionDesignManager.macros_manager.getControls ();
168 }
169 if(type.equals ("CDM.GUI.SuperCollection")) {
170 return CollectionDesignManager.supercollection_manager.getControls ();
171 }
172 if(type.equals ("CDM.GUI.DepositorMetadata")) {
173 return CollectionDesignManager.depositormetadata_manager.getControls ();
174 }
175 return null;
176 }
177
178 private int page_type = PreviewButton.HOME_PAGE;
179 private String page_params = "";
180 public int getPageType () {
181 System.err.println ("view type = "+view_type);
182 if (view_type.equals ("CDM.GUI.General") || view_type.equals ("CDM.GUI.Translation")) {
183 page_type = PreviewButton.HOME_PAGE;
184 } else {
185
186 if (Gatherer.GS3 == true) {
187 Format4gs3 current_format = ((Format4gs3Manager.FormatControl)view).getCurrentFormat ();
188 String feature_name = current_format.getFeatureName ();
189
190 if (feature_name.equals ("browse")) {
191 page_type = PreviewButton.CLASSIFIER_PAGE;
192 page_params = "CL1";
193 } else
194 if (feature_name.startsWith ("CL")) {
195 page_type = PreviewButton.CLASSIFIER_PAGE;
196 page_params = current_format.getFeatureName ();
197 }
198 else if (feature_name.startsWith ("display")) {
199 page_type = PreviewButton.DOCUMENT_PAGE;
200 page_params = "HASH01e4da6100fdbb11b7ef244b";
201 }
202 else if (feature_name.equals ("search")) {
203 page_type = PreviewButton.SEARCH_PAGE;
204 page_params = "the";
205 } else { // HOME_PAGE
206 }
207 } else {
208 Format current_format = ((FormatManager.FormatControl)view).getCurrentFormat ();
209 String feature_name = current_format.getFeatureName ();
210 System.err.println ("current format = "+feature_name);
211 if (feature_name.equals ("")) {
212 // must be modifying VList or HList
213 // what should we do???
214 page_type = PreviewButton.CLASSIFIER_PAGE;
215 page_params = "CL1";
216 }
217 if (feature_name.startsWith ("CL")) {
218 page_type = PreviewButton.CLASSIFIER_PAGE;
219 page_params = current_format.getFeatureName ();
220 }
221 else if (feature_name.startsWith ("Document")) {
222 page_type = PreviewButton.DOCUMENT_PAGE;
223 page_params = "HASH01e4da6100fdbb11b7ef244b";
224 }
225 else if (feature_name.equals ("Search")) {
226 page_type = PreviewButton.SEARCH_PAGE;
227 page_params = "the";
228 }
229 }
230 }
231 return page_type;
232 }
233
234 public String getPageParams () {
235 return page_params;
236 }
237
238}
Note: See TracBrowser for help on using the repository browser.