[12057] | 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 | * Copyright (C) 2006 New Zealand Digital Library Project
|
---|
| 9 | *
|
---|
| 10 | * <BR><BR>
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or modify
|
---|
| 13 | * it under the terms of the GNU General Public License as published by
|
---|
| 14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | * (at your option) any later version.
|
---|
| 16 | *
|
---|
| 17 | * <BR><BR>
|
---|
| 18 | *
|
---|
| 19 | * This program is distributed in the hope that it will be useful,
|
---|
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 22 | * GNU General Public License for more details.
|
---|
| 23 | *
|
---|
| 24 | * <BR><BR>
|
---|
| 25 | *
|
---|
| 26 | * You should have received a copy of the GNU General Public License
|
---|
| 27 | * along with this program; if not, write to the Free Software
|
---|
| 28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 29 | *########################################################################
|
---|
| 30 | */
|
---|
| 31 | package org.greenstone.gatherer.gui;
|
---|
| 32 |
|
---|
| 33 | import java.awt.*;
|
---|
| 34 | import java.awt.event.*;
|
---|
| 35 | import javax.swing.*;
|
---|
| 36 | import org.greenstone.gatherer.Configuration;
|
---|
[19544] | 37 | import org.greenstone.gatherer.Dictionary;
|
---|
[12057] | 38 | import org.greenstone.gatherer.Gatherer;
|
---|
[13595] | 39 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
[13592] | 40 | import org.greenstone.gatherer.greenstone.LocalLibraryServer;
|
---|
[13835] | 41 | import org.greenstone.gatherer.greenstone3.ServletConfiguration;
|
---|
[12057] | 42 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | public class PreviewButton
|
---|
| 46 | extends GLIButton {
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | static final public int HOME_PAGE = 1;
|
---|
| 50 | static final public int SEARCH_PAGE = 2;
|
---|
| 51 | static final public int CLASSIFIER_PAGE = 3;
|
---|
| 52 | static final public int DOCUMENT_PAGE = 4;
|
---|
| 53 |
|
---|
| 54 | private String preview_address;
|
---|
| 55 | private int page_type = HOME_PAGE;
|
---|
| 56 | private boolean variable_preview = false;
|
---|
| 57 |
|
---|
| 58 | private PreviewButtonOwner owner = null;
|
---|
| 59 | public PreviewButton() {
|
---|
| 60 | super();
|
---|
| 61 | PreviewButtonListener pbl = new PreviewButtonListener();
|
---|
| 62 | addActionListener(pbl);
|
---|
| 63 | }
|
---|
[12116] | 64 | public PreviewButton(String text, String tooltip) {
|
---|
| 65 | super(text, tooltip);
|
---|
| 66 | PreviewButtonListener pbl = new PreviewButtonListener();
|
---|
| 67 | addActionListener(pbl);
|
---|
| 68 | }
|
---|
[12057] | 69 |
|
---|
| 70 | public void setOwner(PreviewButtonOwner o) {
|
---|
| 71 | owner = o;
|
---|
| 72 | }
|
---|
| 73 | public void setVariablePreview(boolean vp) {
|
---|
| 74 | variable_preview = vp;
|
---|
| 75 | }
|
---|
| 76 | protected void configureHomeURL() {
|
---|
[19041] | 77 | // we could be working with standalone collections or collection groups
|
---|
| 78 | // so getting a collection-name may have a collection group prefix
|
---|
| 79 | // This means CollectionManager.getLoadedCollectionName() is no longer sufficient
|
---|
[19203] | 80 | String collGroupWithName = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
|
---|
[19041] | 81 |
|
---|
[12057] | 82 | // set up the home page for the current collection
|
---|
[15361] | 83 | if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case
|
---|
[19862] | 84 | if(Configuration.library_url == null) {
|
---|
| 85 | Gatherer.missingEXEC();
|
---|
[19863] | 86 | }
|
---|
| 87 | // if we now finally have a library URL, then continue with previewing
|
---|
| 88 | if(Configuration.library_url != null) {
|
---|
[19862] | 89 | // don't do anything fancy here
|
---|
| 90 | preview_address = Configuration.library_url.toString() + Configuration.getServletPath()
|
---|
| 91 | + "?a=p&sa=about&c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
|
---|
| 92 | }
|
---|
[12057] | 93 | return;
|
---|
| 94 | }
|
---|
[18987] | 95 |
|
---|
[19758] | 96 | if(Gatherer.isLocalLibrary) {
|
---|
[19598] | 97 | // check that the local library server is still running - doesn't do anything if it's not supposed to be running
|
---|
| 98 | // !! Don't like this here
|
---|
| 99 | LocalLibraryServer.checkServerRunning();
|
---|
[19758] | 100 | if(LocalLibraryServer.isURLPending()) {
|
---|
[19598] | 101 | // Remind the user to press Enter Library, and return from this method
|
---|
| 102 | JOptionPane.showMessageDialog(Gatherer.g_man,
|
---|
| 103 | Dictionary.get("General.LLS_Not_Started"),
|
---|
| 104 | Dictionary.get("General.LLS_Not_Started_Title"),
|
---|
[20952] | 105 | JOptionPane.INFORMATION_MESSAGE);
|
---|
[19598] | 106 | preview_address = null;
|
---|
| 107 | return;
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
[15361] | 110 | // FLI or GLI for GS2 case (no library_url)
|
---|
[19041] | 111 | preview_address = Configuration.library_url.toString() + "?c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
|
---|
[12057] | 112 |
|
---|
| 113 | String main_args = "&a=p&p=about";
|
---|
| 114 | /* this code is for switching the preview page depending on what
|
---|
| 115 | is currently active. but it is not complete yet
|
---|
| 116 | String main_args = null;
|
---|
| 117 | String params = null;
|
---|
| 118 | if (!variable_preview || owner == null) {
|
---|
| 119 | main_args = "&a=p&p=about";
|
---|
| 120 | } else {
|
---|
| 121 | page_type = owner.getPageType();
|
---|
| 122 | params = owner.getPageParams();
|
---|
| 123 |
|
---|
| 124 | switch (page_type) {
|
---|
| 125 | case SEARCH_PAGE:
|
---|
| 126 | main_args = "&a=q&q="+params;
|
---|
| 127 | break;
|
---|
| 128 | case CLASSIFIER_PAGE:
|
---|
| 129 | main_args = "&a=d&cl="+params;
|
---|
| 130 | break;
|
---|
| 131 | case DOCUMENT_PAGE:
|
---|
| 132 | main_args = "&a=d&d="+params;
|
---|
| 133 | break;
|
---|
| 134 | case HOME_PAGE:
|
---|
| 135 | default:
|
---|
| 136 | main_args = "&a=p&p=about";
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | }
|
---|
| 143 | */
|
---|
| 144 | preview_address += main_args+StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
|
---|
| 145 |
|
---|
| 146 | }
|
---|
| 147 | private class PreviewButtonListener
|
---|
| 148 | implements ActionListener {
|
---|
| 149 |
|
---|
| 150 | public void actionPerformed(ActionEvent event) {
|
---|
[12805] | 151 | Gatherer.c_man.saveCollection();
|
---|
[12057] | 152 |
|
---|
[19547] | 153 | configureHomeURL();
|
---|
[18987] | 154 |
|
---|
[13835] | 155 | if (Gatherer.GS3) {
|
---|
| 156 | // we need to rerun the convert in case the format stuff has changed
|
---|
[14046] | 157 | //for gs3, we don't need this anymore: Gatherer.c_man.convertToGS3Collection();
|
---|
[13835] | 158 | Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + Gatherer.c_man.getLoadedCollectionName());
|
---|
| 159 | }
|
---|
[19547] | 160 | if(preview_address != null) {
|
---|
| 161 | Gatherer.spawnBrowser(preview_address);
|
---|
| 162 | }
|
---|
[12057] | 163 |
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | }
|
---|