[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;
|
---|
| 37 | import org.greenstone.gatherer.Gatherer;
|
---|
[13595] | 38 | import org.greenstone.gatherer.collection.CollectionManager;
|
---|
[13592] | 39 | import org.greenstone.gatherer.greenstone.LocalLibraryServer;
|
---|
[13835] | 40 | import org.greenstone.gatherer.greenstone3.ServletConfiguration;
|
---|
[12057] | 41 | import org.greenstone.gatherer.util.StaticStrings;
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | public class PreviewButton
|
---|
| 45 | extends GLIButton {
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | static final public int HOME_PAGE = 1;
|
---|
| 49 | static final public int SEARCH_PAGE = 2;
|
---|
| 50 | static final public int CLASSIFIER_PAGE = 3;
|
---|
| 51 | static final public int DOCUMENT_PAGE = 4;
|
---|
| 52 |
|
---|
| 53 | private String preview_address;
|
---|
| 54 | private int page_type = HOME_PAGE;
|
---|
| 55 | private boolean variable_preview = false;
|
---|
| 56 |
|
---|
| 57 | private PreviewButtonOwner owner = null;
|
---|
| 58 | public PreviewButton() {
|
---|
| 59 | super();
|
---|
| 60 | PreviewButtonListener pbl = new PreviewButtonListener();
|
---|
| 61 | addActionListener(pbl);
|
---|
| 62 | }
|
---|
[12116] | 63 | public PreviewButton(String text, String tooltip) {
|
---|
| 64 | super(text, tooltip);
|
---|
| 65 | PreviewButtonListener pbl = new PreviewButtonListener();
|
---|
| 66 | addActionListener(pbl);
|
---|
| 67 | }
|
---|
[12057] | 68 |
|
---|
| 69 | public void setOwner(PreviewButtonOwner o) {
|
---|
| 70 | owner = o;
|
---|
| 71 | }
|
---|
| 72 | public void setVariablePreview(boolean vp) {
|
---|
| 73 | variable_preview = vp;
|
---|
| 74 | }
|
---|
| 75 | protected void configureHomeURL() {
|
---|
[19041] | 76 | // we could be working with standalone collections or collection groups
|
---|
| 77 | // so getting a collection-name may have a collection group prefix
|
---|
| 78 | // This means CollectionManager.getLoadedCollectionName() is no longer sufficient
|
---|
[19203] | 79 | String collGroupWithName = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
|
---|
[19041] | 80 |
|
---|
[12057] | 81 | // set up the home page for the current collection
|
---|
[15361] | 82 | if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case
|
---|
[12057] | 83 | // don't do anything fancy here
|
---|
[19041] | 84 | preview_address = Configuration.library_url.toString() + Configuration.getServletPath()
|
---|
| 85 | + "?a=p&sa=about&c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
|
---|
[12057] | 86 | return;
|
---|
| 87 | }
|
---|
[18987] | 88 |
|
---|
| 89 | // check that the local library server is still running - doesn't do anything if it's not supposed to be running
|
---|
| 90 | // !! Don't like this here
|
---|
| 91 | LocalLibraryServer.checkServerRunning();
|
---|
| 92 |
|
---|
[15361] | 93 | // FLI or GLI for GS2 case (no library_url)
|
---|
[19041] | 94 | preview_address = Configuration.library_url.toString() + "?c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
|
---|
[12057] | 95 |
|
---|
| 96 | String main_args = "&a=p&p=about";
|
---|
| 97 | /* this code is for switching the preview page depending on what
|
---|
| 98 | is currently active. but it is not complete yet
|
---|
| 99 | String main_args = null;
|
---|
| 100 | String params = null;
|
---|
| 101 | if (!variable_preview || owner == null) {
|
---|
| 102 | main_args = "&a=p&p=about";
|
---|
| 103 | } else {
|
---|
| 104 | page_type = owner.getPageType();
|
---|
| 105 | params = owner.getPageParams();
|
---|
| 106 |
|
---|
| 107 | switch (page_type) {
|
---|
| 108 | case SEARCH_PAGE:
|
---|
| 109 | main_args = "&a=q&q="+params;
|
---|
| 110 | break;
|
---|
| 111 | case CLASSIFIER_PAGE:
|
---|
| 112 | main_args = "&a=d&cl="+params;
|
---|
| 113 | break;
|
---|
| 114 | case DOCUMENT_PAGE:
|
---|
| 115 | main_args = "&a=d&d="+params;
|
---|
| 116 | break;
|
---|
| 117 | case HOME_PAGE:
|
---|
| 118 | default:
|
---|
| 119 | main_args = "&a=p&p=about";
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | }
|
---|
| 126 | */
|
---|
| 127 | preview_address += main_args+StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
|
---|
| 128 |
|
---|
| 129 | }
|
---|
| 130 | private class PreviewButtonListener
|
---|
| 131 | implements ActionListener {
|
---|
| 132 |
|
---|
| 133 | public void actionPerformed(ActionEvent event) {
|
---|
[12805] | 134 | Gatherer.c_man.saveCollection();
|
---|
[12057] | 135 |
|
---|
[19513] | 136 | configureHomeURL();
|
---|
[18987] | 137 |
|
---|
[13835] | 138 | if (Gatherer.GS3) {
|
---|
| 139 | // we need to rerun the convert in case the format stuff has changed
|
---|
[14046] | 140 | //for gs3, we don't need this anymore: Gatherer.c_man.convertToGS3Collection();
|
---|
[13835] | 141 | Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + Gatherer.c_man.getLoadedCollectionName());
|
---|
| 142 | }
|
---|
[12057] | 143 | Gatherer.spawnBrowser(preview_address);
|
---|
| 144 |
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | }
|
---|