source: gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/FormatPane.java@ 18297

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

interface updated to display right to left for rtl languages. This code is thanks to Amin Hejazi. It seems to be only partially complete. Amin was working with Greenstone 3 so might have missed some panels

  • 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" };
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 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.