source: gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/PreviewButton.java@ 18364

Last change on this file since 18364 was 18364, checked in by kjdon, 15 years ago

updated the rtl-gli branch with files from trunk. Result of a merge 14807:18318, and fixed some conflicts. I think this is the last commit following merging the files. Haven't tried to compile yet... here goes...

  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 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.Gatherer;
38import org.greenstone.gatherer.collection.CollectionManager;
39import org.greenstone.gatherer.greenstone.LocalLibraryServer;
40import org.greenstone.gatherer.greenstone3.ServletConfiguration;
41import org.greenstone.gatherer.util.StaticStrings;
42
43
44public 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 }
63 public PreviewButton(String text, String tooltip) {
64 super(text, tooltip);
65 PreviewButtonListener pbl = new PreviewButtonListener();
66 addActionListener(pbl);
67 }
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() {
76 // set up the home page for the current collection
77 if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case
78 // don't do anything fancy here
79 preview_address = Configuration.library_url.toString() + Configuration.getServletPath() + "?a=p&sa=about&c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage();
80 return;
81 }
82 // FLI or GLI for GS2 case (no library_url)
83 preview_address = Configuration.library_url.toString() + "?c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage();
84
85 String main_args = "&a=p&p=about";
86 /* this code is for switching the preview page depending on what
87 is currently active. but it is not complete yet
88 String main_args = null;
89 String params = null;
90 if (!variable_preview || owner == null) {
91 main_args = "&a=p&p=about";
92 } else {
93 page_type = owner.getPageType();
94 params = owner.getPageParams();
95
96 switch (page_type) {
97 case SEARCH_PAGE:
98 main_args = "&a=q&q="+params;
99 break;
100 case CLASSIFIER_PAGE:
101 main_args = "&a=d&cl="+params;
102 break;
103 case DOCUMENT_PAGE:
104 main_args = "&a=d&d="+params;
105 break;
106 case HOME_PAGE:
107 default:
108 main_args = "&a=p&p=about";
109
110
111 }
112
113
114 }
115 */
116 preview_address += main_args+StaticStrings.TIMESTAMP_ARGUMENT + System.currentTimeMillis();
117
118 }
119 private class PreviewButtonListener
120 implements ActionListener {
121
122 public void actionPerformed(ActionEvent event) {
123 Gatherer.c_man.saveCollection();
124
125 configureHomeURL();
126 // check that the local library server is still running - doesn't do anything if its not supposed to be running
127 // !! Don't like this here
128 LocalLibraryServer.checkServerRunning();
129 if (Gatherer.GS3) {
130 // we need to rerun the convert in case the format stuff has changed
131 //for gs3, we don't need this anymore: Gatherer.c_man.convertToGS3Collection();
132 Gatherer.configGS3Server(Configuration.site_name, ServletConfiguration.ADD_COMMAND + Gatherer.c_man.getLoadedCollectionName());
133 }
134 Gatherer.spawnBrowser(preview_address);
135
136 }
137
138 }
139
140}
Note: See TracBrowser for help on using the repository browser.