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

Last change on this file since 18376 was 18370, checked in by kjdon, 15 years ago

committed code submitted by Amin Hedjazi for making the GLI right to left. I worked on this code on the rtl-gli branch, then merged the branch back to the trunk at revision 18368. The branch code was slightly different in a couple of places where it shouldn't have been. So don't use the branch code next time. Start a new branch.

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