source: gli/trunk/src/org/greenstone/gatherer/gui/PreviewButton.java@ 19862

Last change on this file since 19862 was 19862, checked in by ak19, 15 years ago

Getting the preview button working again for GS3.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
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 */
31package org.greenstone.gatherer.gui;
32
33import java.awt.*;
34import java.awt.event.*;
35import javax.swing.*;
36import org.greenstone.gatherer.Configuration;
37import org.greenstone.gatherer.Dictionary;
38import org.greenstone.gatherer.Gatherer;
39import org.greenstone.gatherer.collection.CollectionManager;
40import org.greenstone.gatherer.greenstone.LocalLibraryServer;
41import org.greenstone.gatherer.greenstone3.ServletConfiguration;
42import org.greenstone.gatherer.util.StaticStrings;
43
44
45public 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 }
64 public PreviewButton(String text, String tooltip) {
65 super(text, tooltip);
66 PreviewButtonListener pbl = new PreviewButtonListener();
67 addActionListener(pbl);
68 }
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() {
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
80 String collGroupWithName = CollectionManager.getLoadedGroupQualifiedCollectionName(true);
81
82 // set up the home page for the current collection
83 if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case
84 if(Configuration.library_url == null) {
85 Gatherer.missingEXEC();
86 } else {
87 // don't do anything fancy here
88 preview_address = Configuration.library_url.toString() + Configuration.getServletPath()
89 + "?a=p&sa=about&c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
90 }
91 return;
92 }
93
94 if(Gatherer.isLocalLibrary) {
95 // check that the local library server is still running - doesn't do anything if it's not supposed to be running
96 // !! Don't like this here
97 LocalLibraryServer.checkServerRunning();
98 if(LocalLibraryServer.isURLPending()) {
99 // Remind the user to press Enter Library, and return from this method
100 JOptionPane.showMessageDialog(Gatherer.g_man,
101 Dictionary.get("General.LLS_Not_Started"),
102 Dictionary.get("General.LLS_Not_Started_Title"),
103 JOptionPane.ERROR_MESSAGE);
104 preview_address = null;
105 return;
106 }
107 }
108 // FLI or GLI for GS2 case (no library_url)
109 preview_address = Configuration.library_url.toString() + "?c=" + collGroupWithName + "&l=" + Configuration.getLanguage();
110
111 String main_args = "&a=p&p=about";
112 /* this code is for switching the preview page depending on what
113 is currently active. but it is not complete yet
114 String main_args = null;
115 String params = null;
116 if (!variable_preview || owner == null) {
117 main_args = "&a=p&p=about";
118 } else {
119 page_type = owner.getPageType();
120 params = owner.getPageParams();
121
122 switch (page_type) {
123 case SEARCH_PAGE:
124 main_args = "&a=q&q="+params;
125 break;
126 case CLASSIFIER_PAGE:
127 main_args = "&a=d&cl="+params;
128 break;
129 case DOCUMENT_PAGE:
130 main_args = "&a=d&d="+params;
131 break;
132 case HOME_PAGE:
133 default:
134 main_args = "&a=p&p=about";
135
136
137 }
138
139
140 }
141 */
142 preview_address += main_args+StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
143
144 }
145 private class PreviewButtonListener
146 implements ActionListener {
147
148 public void actionPerformed(ActionEvent event) {
149 Gatherer.c_man.saveCollection();
150
151 configureHomeURL();
152
153 if (Gatherer.GS3) {
154 // we need to rerun the convert in case the format stuff has changed
155 //for gs3, we don't need this anymore: Gatherer.c_man.convertToGS3Collection();
156 Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + Gatherer.c_man.getLoadedCollectionName());
157 }
158 if(preview_address != null) {
159 Gatherer.spawnBrowser(preview_address);
160 }
161
162 }
163
164 }
165
166}
Note: See TracBrowser for help on using the repository browser.