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