
java.fedora.client.search.ResultFrame Maven / Gradle / Ivy
Show all versions of fcrepo-client Show documentation
/*
* -----------------------------------------------------------------------------
*
* License and Copyright: The contents of this file are subject to the
* Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of
* the License at
* http://www.fedora-commons.org/licenses.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The entire file consists of original code.
* Copyright © 2008 Fedora Commons, Inc.
*
Copyright © 2002-2007 The Rector and Visitors of the University of
* Virginia and Cornell University
* All rights reserved.
*
* -----------------------------------------------------------------------------
*/
package fedora.client.search;
import javax.swing.*;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.basic.BasicTableUI;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import fedora.swing.jtable.DefaultSortTableModel;
import fedora.swing.jtable.JSortTable;
import fedora.client.Administrator;
import fedora.client.actions.ChangeObjectState;
import fedora.client.actions.ExportObject;
import fedora.client.actions.PurgeObject;
import fedora.client.actions.ViewObject;
import fedora.client.actions.ViewObjectXML;
import fedora.client.utility.AutoFinder;
import fedora.server.types.gen.ObjectFields;
import fedora.server.types.gen.FieldSearchQuery;
import fedora.server.types.gen.FieldSearchResult;
/**
*
* Title: ResultFrame.java
* Description:
*
* @author [email protected]
* @version $Id: ResultFrame.java 5162 2006-10-25 00:49:06Z eddie $
*/
public class ResultFrame
extends JInternalFrame {
private static final long serialVersionUID = 1L;
private JSortTable m_table;
private String[] m_rowPids;
private JButton m_moreButton;
private AutoFinder m_finder=null;
public ResultFrame(String frameTitle, String[] displayFields, String sessionToken) {
super(frameTitle, true, true, true, true);
try {
m_finder=new AutoFinder(Administrator.APIA);
searchAndDisplay(m_finder.resumeFindObjects(sessionToken),
displayFields);
} catch (Exception e) {
e.printStackTrace();
System.out.println("ERROR: " + e.getClass().getName() + ":" + e.getMessage());
}
}
public ResultFrame(String frameTitle, String[] displayFields, int maxResults, FieldSearchQuery query) {
super(frameTitle,
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
// Make sure resultFields has pid, even though they may not
// want to display it. Also, signal that the pid should or
// should not be displayed.
boolean displayPid=false;
for (int i=0; i0) out.append(", ");
out.append(s[i]);
}
return out.toString();
}
public class MoreResultsListener
implements ActionListener {
String[] m_displayFields;
String m_sessionToken;
ResultFrame m_parent;
public MoreResultsListener(String[] displayFields, String sessionToken,
ResultFrame parent) {
m_displayFields=displayFields;
m_sessionToken=sessionToken;
m_parent=parent;
}
public void actionPerformed(ActionEvent e) {
m_parent.removeMoreResultsButton();
ResultFrame frame=new ResultFrame("More Search Results",
m_displayFields, m_sessionToken);
frame.setVisible(true);
Administrator.getDesktop().add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException pve) {}
}
}
public class BrowserTableUI
extends BasicTableUI {
protected MouseInputListener createMouseInputListener() {
return new BasicTableUI.MouseInputHandler() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount()==2) {
int rowNum=m_table.rowAtPoint(new Point(e.getX(), e.getY()));
if (rowNum>=0) {
// launch object viewer to view object
new ViewObject(m_rowPids[rowNum]).launch();
}
}
}
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e) ) {
int rowNum=m_table.rowAtPoint(new Point(e.getX(), e.getY()));
if (rowNum >= 0) {
int[] sRows=m_table.getSelectedRows();
boolean clickedOnSelected=false;
HashSet pids=new HashSet();
for (int i=0; i