All Downloads are FREE. Search and download functionalities are using the official Maven repository.

decodes.syncgui.PlatListPanel Maven / Gradle / Ivy

Go to download

A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.

The newest version!
package decodes.syncgui;

import java.awt.*;

import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.awt.event.*;
import java.util.Collections;
import java.util.Comparator;
import java.io.*;
import java.net.URL;

import ilex.gui.FileDownloadDialog;
import ilex.gui.MultFileDownloadDialog;
import ilex.gui.ShowFileDialog;
import ilex.util.EnvExpander;
import ilex.util.FileUtil;
import decodes.gui.SortingListTable;
import decodes.gui.SortingListTableModel;


/**
 * This panel displays this list of platforms.
 */
public class PlatListPanel extends JPanel 
{
	BorderLayout borderLayout1 = new BorderLayout();
	JPanel jPanel1 = new JPanel();
	JLabel jLabel1 = new JLabel();
	JTextField dbNameField = new JTextField();
	FlowLayout flowLayout1 = new FlowLayout();
	JPanel buttonPanel = new JPanel();
	JButton importButton = new JButton();
	JButton downloadButton = new JButton();
	JButton viewButton = new JButton();
	FlowLayout flowLayout2 = new FlowLayout();
	JScrollPane jScrollPane1 = new JScrollPane();
	JTable platListTable;
	private ShowFileDialog showFileDialog = null;
	
	static private JFileChooser jFileChooser = new JFileChooser();
	static
	{
		jFileChooser.setCurrentDirectory(
			new File(EnvExpander.expand("$DECODES_INSTALL_DIR")));
	}


	/** The plat list being shown */
	PlatList platList;
	PlatListTableModel model;

	/** Constructor -- must be no-args for JBuilder */
	public PlatListPanel() 
	{
		platList = null;
		model = new PlatListTableModel(this);
		platListTable = new SortingListTable(model, 
			new int[] { 15, 10, 13, 18, 15, 40 });
		
		try {
			jbInit();
		}
		catch(Exception ex) {
			ex.printStackTrace();
		}
	}

	void jbInit() throws Exception {
		this.setLayout(borderLayout1);
		jLabel1.setText("Platforms in database: ");
		dbNameField.setPreferredSize(new Dimension(180, 23));
		dbNameField.setEditable(false);
		dbNameField.setText("MVM 2004-08-20 00:05");
		jPanel1.setLayout(flowLayout1);
		importButton.setPreferredSize(new Dimension(100, 27));
		importButton.setToolTipText("Import selected platforms to your Edit Database");
		importButton.setText("Import");
		importButton.addActionListener(
			new java.awt.event.ActionListener() 
			{
	            public void actionPerformed(ActionEvent e) 
	            {
	                importPressed();
	            }
	        });
		downloadButton.setPreferredSize(new Dimension(100, 27));
		downloadButton.setToolTipText("Download selected platforms to XML files to be imported later.");
		downloadButton.setText("Download");
		downloadButton.addActionListener(
			new java.awt.event.ActionListener() 
			{
	            public void actionPerformed(ActionEvent e) 
	            {
	                downloadPressed();
	            }
	        });
		viewButton.setText("View");
		viewButton.setPreferredSize(new Dimension(100, 27));
		viewButton.setToolTipText("View selected platform XML.");
		viewButton.addActionListener(
			new java.awt.event.ActionListener() 
			{
	            public void actionPerformed(ActionEvent e) 
	            {
	                viewPressed();
	            }
	        });
		buttonPanel.setLayout(flowLayout2);
		flowLayout2.setHgap(25);
		flowLayout2.setVgap(10);
		this.add(jPanel1, BorderLayout.NORTH);
		jPanel1.add(jLabel1, null);
		jPanel1.add(dbNameField, null);
		this.add(buttonPanel, BorderLayout.SOUTH);
		buttonPanel.add(importButton, null);
		buttonPanel.add(downloadButton, null);
		buttonPanel.add(viewButton, null);
		this.add(jScrollPane1, BorderLayout.CENTER);
		jScrollPane1.getViewport().add(platListTable, null);
	}

	/**
	  Sets the platform list being shown.
	  @param platList the platform list.
	*/
	public void setPlatList(PlatList platList)
	{
		this.platList = platList;
//System.out.println("Editing PlatList with " + this.platList.getEntries().size()
//+ " entries.");
		model.fireTableDataChanged();
	}

	void importPressed() 
	{
		int n = platListTable.getSelectedRowCount();
		if (n == 0)
			return;

		String decHomePath = EnvExpander.expand("$DECODES_INSTALL_DIR");
		DistrictDBSnap snapshot = platList.myDB;
		String tmpPath = decHomePath + "/tmp";
		File tmpDir = new File(tmpPath);
		if (!tmpDir.isDirectory() && !tmpDir.mkdirs())
		{
			SyncGuiFrame.instance().showError("The directory '"
				+ tmpPath + " does not exist and cannot be created!");
			return;
		}

		String urldir =
			SyncConfig.instance().getHubHome() + "/"
			+ snapshot.getDistrict().getName() + "/"
			+ snapshot.getDirName() + "/platform";
		int rows[] = platListTable.getSelectedRows();
		String files[] = new String[n];
		for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy