/*
* PaperInfoWindow.java
*
* Created on 05 September 2007, 13:39
*/
/**
*
* @author Mark
*/
package paperscope;
import prefuse.Visualization;
import prefuse.visual.VisualItem;
import edu.stanford.ejalbert.BrowserLauncher;
public class PaperInfoWindow extends javax.swing.JFrame {
/** Creates new form paperInfoWindow */
public PaperInfoWindow(Visualization v, VisualItem item) {
initComponents();
this.v = v;
this.item = item;
insertText();
this.setVisible(true);
}
public void insertText()
{
this.setTitle("Paper information for: " + v.getSourceTuple(item).getString("bibcode"));
this.titleText.setText(v.getSourceTuple(item).getString("title"));
this.authorText.setText(v.getSourceTuple(item).getString("authorList"));
this.journalText.setText(v.getSourceTuple(item).getString("journal"));
this.abstractURLText.setText(v.getSourceTuple(item).getString("abstractURL"));
this.dateText.setText(v.getSourceTuple(item).getString("date"));
this.citCountText.setText(v.getSourceTuple(item).getString("citCount"));
String realBibcode = v.getSourceTuple(item).getString("bibcode").replace(";amp", "&");
this.bibcodeText.setText(realBibcode);
this.commentText.setText(v.getSourceTuple(item).getString("comment"));
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
titleLabel = new javax.swing.JLabel();
titleText = new javax.swing.JTextField();
authorLabel = new javax.swing.JLabel();
authorText = new javax.swing.JTextField();
journalLabel = new javax.swing.JLabel();
journalText = new javax.swing.JTextField();
abstractURLLabel = new javax.swing.JLabel();
abstractURLText = new javax.swing.JTextField();
dateLabel = new javax.swing.JLabel();
dateText = new javax.swing.JTextField();
citCountLabel = new javax.swing.JLabel();
citCountText = new javax.swing.JTextField();
bibcodeLabel = new javax.swing.JLabel();
bibcodeText = new javax.swing.JTextField();
commentLabel = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
commentText = new javax.swing.JTextArea();
editCommentsButton = new javax.swing.JButton();
readAbstractButton = new javax.swing.JButton();
closeButton = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
saveMessageLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
titleLabel.setText("Title: ");
titleText.setEditable(false);
authorLabel.setText("Authors: ");
authorText.setEditable(false);
journalLabel.setText("Journal: ");
journalText.setEditable(false);
abstractURLLabel.setText("Abstract URL: ");
abstractURLText.setEditable(false);
dateLabel.setText("Date: ");
dateText.setColumns(8);
dateText.setEditable(false);
citCountLabel.setText("Citation Count: ");
citCountText.setColumns(5);
citCountText.setEditable(false);
bibcodeLabel.setText("Bibcode: ");
bibcodeText.setColumns(20);
bibcodeText.setEditable(false);
commentLabel.setText("Comments: ");
commentText.setColumns(20);
commentText.setLineWrap(true);
commentText.setRows(5);
jScrollPane1.setViewportView(commentText);
editCommentsButton.setText("Save Comments");
editCommentsButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
editCommentsButtonMouseClicked(evt);
}
});
readAbstractButton.setText("Read Abstract");
readAbstractButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
readAbstractButtonMouseClicked(evt);
}
});
closeButton.setText("Close");
closeButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
closeButtonMouseClicked(evt);
}
});
saveMessageLabel.setFont(new java.awt.Font("Tahoma", 0, 10));
saveMessageLabel.setText(" ");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(titleLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(titleText, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(authorLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(authorText, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(journalLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(journalText, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(abstractURLLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(abstractURLText, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(dateLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dateText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(15, 15, 15)
.addComponent(citCountLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(citCountText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(bibcodeLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(bibcodeText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 517, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addComponent(commentLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(saveMessageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
.addComponent(editCommentsButton)
.addGap(20, 20, 20)
.addComponent(readAbstractButton)
.addGap(16, 16, 16)
.addComponent(closeButton)
.addGap(20, 20, 20))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE)
.addContainerGap())))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(titleLabel)
.addComponent(titleText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(authorLabel)
.addComponent(authorText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(journalLabel)
.addComponent(journalText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(abstractURLText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(abstractURLLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(dateLabel)
.addComponent(dateText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(citCountLabel)
.addComponent(citCountText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bibcodeLabel)
.addComponent(bibcodeText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(commentLabel)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(editCommentsButton)
.addComponent(readAbstractButton)
.addComponent(closeButton)))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveMessageLabel)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void closeButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_closeButtonMouseClicked
this.dispose();
}//GEN-LAST:event_closeButtonMouseClicked
private void readAbstractButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_readAbstractButtonMouseClicked
try
{
//==== Get the Abstract URL
String abstractURL = (v.getSourceTuple(item)).getString("abstractURL");
//==== Create the browser launcher, open the URL in the user's browser
BrowserLauncher launch = new BrowserLauncher();
launch.openURLinBrowser(abstractURL);
}
catch (Exception e){
System.out.println(e);
}
}//GEN-LAST:event_readAbstractButtonMouseClicked
private void editCommentsButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editCommentsButtonMouseClicked
v.getSourceTuple(item).setString("comment", commentText.getText());
//=== If the field is blank, reset the commentStatus to false (for shape rendering)
if(commentText.getText().equals(""))
{
v.getSourceTuple(item).setString("commentStatus", "f");
v.getFocusGroup("commentHighlight").removeTuple(v.getVisualItem("tree.nodes", v.getSourceTuple(item)));
}
else
{
v.getSourceTuple(item).setString("commentStatus", "t");
v.getFocusGroup("commentHighlight").addTuple(v.getVisualItem("tree.nodes", v.getSourceTuple(item)));
}
this.saveMessageLabel.setText("Comments saved");
v.run("repaint");
}//GEN-LAST:event_editCommentsButtonMouseClicked
private Visualization v;
private VisualItem item;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel abstractURLLabel;
private javax.swing.JTextField abstractURLText;
private javax.swing.JLabel authorLabel;
private javax.swing.JTextField authorText;
private javax.swing.JLabel bibcodeLabel;
private javax.swing.JTextField bibcodeText;
private javax.swing.JLabel citCountLabel;
private javax.swing.JTextField citCountText;
private javax.swing.JButton closeButton;
private javax.swing.JLabel commentLabel;
private javax.swing.JTextArea commentText;
private javax.swing.JLabel dateLabel;
private javax.swing.JTextField dateText;
private javax.swing.JButton editCommentsButton;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JLabel journalLabel;
private javax.swing.JTextField journalText;
private javax.swing.JButton readAbstractButton;
private javax.swing.JLabel saveMessageLabel;
private javax.swing.JLabel titleLabel;
private javax.swing.JTextField titleText;
// End of variables declaration//GEN-END:variables
}