decodes.syncgui.FileListPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opendcs Show documentation
Show all versions of opendcs Show documentation
A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.
The newest version!
package decodes.syncgui;
import java.io.File;
import java.io.IOException;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import ilex.gui.MultFileDownloadDialog;
import ilex.util.EnvExpander;
/**
Panel for displaying a list of database XML files.
*/
public class FileListPanel extends JPanel
{
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel dbLabel = new JLabel();
JLabel fileTypeLabel = new JLabel();
JLabel jLabel2 = new JLabel();
JPanel jPanel2 = new JPanel();
JButton importButton = new JButton();
JButton downloadButton = new JButton();
JScrollPane jScrollPane1 = new JScrollPane();
FileListModel fileListModel = new FileListModel();
JList jFileList = new JList(fileListModel);
static private JFileChooser jFileChooser = new JFileChooser();
static
{
jFileChooser.setCurrentDirectory(
new File(EnvExpander.expand("$DECODES_INSTALL_DIR")));
}
public FileListPanel()
{
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception
{
this.setLayout(borderLayout1);
jLabel1.setVerifyInputWhenFocusTarget(true);
jLabel1.setText("Database ");
dbLabel.setText("MVM 2004-08-23 00:04");
fileTypeLabel.setText("Site");
jLabel2.setText("files");
importButton.setPreferredSize(new Dimension(100, 27));
importButton.setToolTipText("Imports selected files to your Edit Database.");
importButton.setText("Import");
importButton.addActionListener(
new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
importButton_actionPerformed(e);
}
});
downloadButton.setPreferredSize(new Dimension(100, 27));
downloadButton.setToolTipText("Download selected XML files to import later.");
downloadButton.setText("Download");
downloadButton.addActionListener(
new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
downloadButton_actionPerformed(e);
}
});
this.add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jLabel1, null);
jPanel1.add(dbLabel, null);
jPanel1.add(fileTypeLabel, null);
jPanel1.add(jLabel2, null);
this.add(jPanel2, BorderLayout.SOUTH);
jPanel2.add(importButton, null);
jPanel2.add(downloadButton, null);
this.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jFileList, null);
}
/** Sets the FileList object being displayed by this panel. */
public void setFileList(FileList fl)
{
fileListModel.setFileList(fl);
dbLabel.setText(fl.getSnap().getFullName());
fileTypeLabel.setText("'" + fl.toString() + "'");
}
void importButton_actionPerformed(ActionEvent e)
{
int idx = jFileList.getSelectedIndex();
if (idx == -1)
return;
Object objs[] = jFileList.getSelectedValues();
String files[] = new String[objs.length];
for(int i=0; i= getSize())
return "";
return fileList.getFileNames().elementAt(index);
}
public int getSize()
{
if (fileList == null)
return 0;
return fileList.size();
}
}