[12058] | 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;
|
---|
[14047] | 48 | import org.greenstone.gatherer.cdm.Format4gs3Manager;
|
---|
| 49 | import org.greenstone.gatherer.cdm.Format4gs3;
|
---|
| 50 | import org.greenstone.gatherer.cdm.DOMProxyListEntry;
|
---|
[12058] | 51 | import org.greenstone.gatherer.cdm.Control;
|
---|
[12423] | 52 | import org.greenstone.gatherer.Configuration;
|
---|
| 53 | import org.greenstone.gatherer.shell.GShell;
|
---|
| 54 | import org.greenstone.gatherer.shell.GShellEvent;
|
---|
| 55 | import org.greenstone.gatherer.shell.GShellListener;
|
---|
[12058] | 56 |
|
---|
[14047] | 57 | public class FormatPane
|
---|
| 58 | extends BaseConfigPane
|
---|
| 59 | implements PreviewButtonOwner,GShellListener{
|
---|
[12058] | 60 |
|
---|
[14047] | 61 |
|
---|
[12058] | 62 | /** The button for viewing the collection. */
|
---|
[14047] | 63 | private static PreviewButton preview_button = null;
|
---|
[12423] | 64 | private boolean buildCanceled = false;
|
---|
[14047] | 65 |
|
---|
[12058] | 66 | /** The constructor. */
|
---|
[14047] | 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 {
|
---|
[16680] | 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" };
|
---|
[14047] | 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);
|
---|
[12058] | 106 | }
|
---|
[14047] | 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 |
|
---|
[12423] | 117 | }
|
---|
[14047] | 118 | public static void setPreviewButton (boolean ready_to_preview) {
|
---|
| 119 | preview_button.setEnabled (ready_to_preview);
|
---|
| 120 | }
|
---|
| 121 |
|
---|
[12423] | 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 | */
|
---|
[14047] | 125 | public synchronized void message (GShellEvent event) {
|
---|
| 126 | // We don't care.
|
---|
[12423] | 127 | }
|
---|
| 128 |
|
---|
[14047] | 129 |
|
---|
[12423] | 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 | */
|
---|
[14047] | 133 | public synchronized void processBegun (GShellEvent event) {
|
---|
| 134 | buildCanceled = false;
|
---|
[12423] | 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 | */
|
---|
[14047] | 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 | }
|
---|
[12423] | 149 | }
|
---|
[14047] | 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 | }
|
---|
[16680] | 172 | if(type.equals ("CDM.GUI.DepositorMetadata")) {
|
---|
| 173 | return CollectionDesignManager.depositormetadata_manager.getControls ();
|
---|
| 174 | }
|
---|
[14047] | 175 | return null;
|
---|
[12058] | 176 | }
|
---|
[14047] | 177 |
|
---|
[12058] | 178 | private int page_type = PreviewButton.HOME_PAGE;
|
---|
| 179 | private String page_params = "";
|
---|
[14047] | 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;
|
---|
[12058] | 232 | }
|
---|
[14047] | 233 |
|
---|
| 234 | public String getPageParams () {
|
---|
| 235 | return page_params;
|
---|
[12058] | 236 | }
|
---|
[14047] | 237 |
|
---|
[12058] | 238 | }
|
---|