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 | */
|
---|
37 | package org.greenstone.gatherer.gui;
|
---|
38 |
|
---|
39 | import java.awt.*;
|
---|
40 | import java.awt.event.*;
|
---|
41 | import javax.swing.*;
|
---|
42 |
|
---|
43 | import org.greenstone.gatherer.Dictionary;
|
---|
44 | import org.greenstone.gatherer.Gatherer;
|
---|
45 | import org.greenstone.gatherer.cdm.CollectionDesignManager;
|
---|
46 | import org.greenstone.gatherer.cdm.FormatManager;
|
---|
47 | import org.greenstone.gatherer.cdm.Format;
|
---|
48 | import org.greenstone.gatherer.cdm.Control;
|
---|
49 | import org.greenstone.gatherer.Configuration;
|
---|
50 | import org.greenstone.gatherer.shell.GShell;
|
---|
51 | import org.greenstone.gatherer.shell.GShellEvent;
|
---|
52 | import org.greenstone.gatherer.shell.GShellListener;
|
---|
53 |
|
---|
54 | public 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 | preview_button = new PreviewButton(Dictionary.get("CreatePane.Preview_Collection"), Dictionary.get("CreatePane.Preview_Collection_Tooltip"));
|
---|
76 | preview_button.setEnabled(true);
|
---|
77 | preview_button.setVariablePreview(true);
|
---|
78 | preview_button.setOwner(this);
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 | preview_button.addActionListener(new ActionListener() {
|
---|
83 | public void actionPerformed(ActionEvent event) {
|
---|
84 | if (view != null) {
|
---|
85 | view.loseFocus();
|
---|
86 | }
|
---|
87 |
|
---|
88 | if (buildCanceled){
|
---|
89 | WarningDialog dialog = new WarningDialog("warning.ShowPreviousCollection", Dictionary.get("ShowPreviousCollection.Title"), Dictionary.get("ShowPreviousCollection.Message"), null, false);
|
---|
90 | dialog.display();
|
---|
91 | dialog.dispose();
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | });
|
---|
96 | side_panel.add(preview_button, BorderLayout.SOUTH);
|
---|
97 |
|
---|
98 | add(side_panel, BorderLayout.WEST);
|
---|
99 | }
|
---|
100 |
|
---|
101 | public void gainFocus(){
|
---|
102 |
|
---|
103 | if (Gatherer.c_man.built() && Configuration.library_url != null) {
|
---|
104 | preview_button.setEnabled(true);
|
---|
105 | }
|
---|
106 | else{
|
---|
107 | preview_button.setEnabled(false);
|
---|
108 | }
|
---|
109 |
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
|
---|
114 | * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
|
---|
115 | */
|
---|
116 | public synchronized void message(GShellEvent event) {
|
---|
117 | // We don't care.
|
---|
118 | }
|
---|
119 |
|
---|
120 |
|
---|
121 | /** 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.
|
---|
122 | * @param event A <strong>GShellEvent</strong> that contains details of the initial state of the <strong>GShell</strong> before task comencement.
|
---|
123 | */
|
---|
124 | public synchronized void processBegun(GShellEvent event) {
|
---|
125 | buildCanceled = false;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /** All implementation of GShellListener must include this method so the listener can be informed when a GShell completes its task.
|
---|
129 | * @param event A <strong>GShellEvent</strong> that contains details of the final state of the <strong>GShell</strong> after task completion.
|
---|
130 | */
|
---|
131 | public synchronized void processComplete(GShellEvent event) {
|
---|
132 | if(event.getStatus() == GShell.OK) {
|
---|
133 | if(event.getType() == GShell.BUILD) {
|
---|
134 | buildCanceled = false;
|
---|
135 | }
|
---|
136 | }
|
---|
137 | else {
|
---|
138 | buildCanceled = true;
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 | protected Control getSubControls(String type) {
|
---|
145 | if(type.equals("CDM.GUI.General")) {
|
---|
146 | return CollectionDesignManager.general_manager.getControls();
|
---|
147 | }
|
---|
148 | if (type.equals("CDM.GUI.SearchMetadata")) {
|
---|
149 | return CollectionDesignManager.searchmetadata_manager.getControls();
|
---|
150 | }
|
---|
151 | if(type.equals("CDM.GUI.Formats")) {
|
---|
152 | return CollectionDesignManager.format_manager.getControls();
|
---|
153 | }
|
---|
154 | if (type.equals("CDM.GUI.Translation")) {
|
---|
155 | return CollectionDesignManager.translation_manager.getControls();
|
---|
156 | }
|
---|
157 | if (type.equals("CDM.GUI.Macros")) {
|
---|
158 | return CollectionDesignManager.macros_manager.getControls();
|
---|
159 | }
|
---|
160 | if(type.equals("CDM.GUI.SuperCollection")) {
|
---|
161 | return CollectionDesignManager.supercollection_manager.getControls();
|
---|
162 | }
|
---|
163 | return null;
|
---|
164 | }
|
---|
165 |
|
---|
166 | private int page_type = PreviewButton.HOME_PAGE;
|
---|
167 | private String page_params = "";
|
---|
168 | public int getPageType() {
|
---|
169 | System.err.println("view type = "+view_type);
|
---|
170 | if (view_type.equals("CDM.GUI.General") || view_type.equals("CDM.GUI.Translation")) {
|
---|
171 | page_type = PreviewButton.HOME_PAGE;
|
---|
172 | } else {
|
---|
173 | Format current_format = ((FormatManager.FormatControl)view).getCurrentFormat();
|
---|
174 | String feature_name = current_format.getFeatureName();
|
---|
175 | System.err.println("current format = "+feature_name);
|
---|
176 | if (feature_name.equals("")) {
|
---|
177 | // must be modifying VList or HList
|
---|
178 | // what should we do???
|
---|
179 | page_type = PreviewButton.CLASSIFIER_PAGE;
|
---|
180 | page_params = "CL1";
|
---|
181 | }
|
---|
182 | if (feature_name.startsWith("CL")) {
|
---|
183 | page_type = PreviewButton.CLASSIFIER_PAGE;
|
---|
184 | page_params = current_format.getFeatureName();
|
---|
185 | }
|
---|
186 | else if (feature_name.startsWith("Document")) {
|
---|
187 | page_type = PreviewButton.DOCUMENT_PAGE;
|
---|
188 | page_params = "HASH01e4da6100fdbb11b7ef244b";
|
---|
189 | }
|
---|
190 | else if (feature_name.equals("Search")) {
|
---|
191 | page_type = PreviewButton.SEARCH_PAGE;
|
---|
192 | page_params = "the";
|
---|
193 | }
|
---|
194 | }
|
---|
195 | return page_type;
|
---|
196 | }
|
---|
197 |
|
---|
198 | public String getPageParams() {
|
---|
199 | return page_params;
|
---|
200 | }
|
---|
201 |
|
---|
202 | }
|
---|