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

decodes.rledit.RefListFrame 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!
/*
*  $Id$
*/
package decodes.rledit;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.*;

import java.util.*;

import ilex.util.*;
import decodes.db.*;
import decodes.decoder.Season;
import decodes.gui.SortingListTable;

/**
RefListFrame is the GUI application for Reference List Editor.
This program allows you to edit DECODES enumerations, engineering
units, EU conversions and data type equivalencies.
*/
@SuppressWarnings("serial")
public class RefListFrame extends JFrame
{
	private static ResourceBundle genericLabels = 
		RefListEditor.getGenericLabels();
	private static ResourceBundle labels = RefListEditor.getLabels();
	private JPanel contentPane;
	private JMenuBar jMenuBar1 = new JMenuBar();
	private JMenu jMenuFile = new JMenu();
	private JMenuItem jMenuFileExit = new JMenuItem();
	private JMenu jMenuHelp = new JMenu();
	private JMenuItem jMenuHelpAbout = new JMenuItem();
	private JLabel statusBar = new JLabel();
	private BorderLayout borderLayout1 = new BorderLayout();
	private JTabbedPane rlTabbedPane = new JTabbedPane();
	private JPanel EnumTab = new JPanel();
	private JPanel EUTab = new JPanel();
	private JPanel EuCnvtTab = new JPanel();
	private JMenuItem mi_saveToDb = new JMenuItem();
	private JTextArea jTextArea1 = new JTextArea();
	private BorderLayout borderLayout2 = new BorderLayout();
	
	private JPanel jPanel1 = new JPanel();
	private JScrollPane jScrollPane1 = new JScrollPane();
	private EnumTableModel enumTableModel = new EnumTableModel();
	private JTable enumTable = new SortingListTable(enumTableModel,
		new int[] { 9, 20, 41, 30 });
	private JButton addEnumValButton = new JButton();
	private JButton editEnumValButton = new JButton();
	private JButton deleteEnumValButton = new JButton();
	private JButton selectEnumValDefaultButton = new JButton();
	private JButton upEnumValButton = new JButton();
	private JButton downEnumValButton = new JButton();
	private JPanel jPanel2 = new JPanel();
	private FlowLayout flowLayout1 = new FlowLayout();
	private JLabel jLabel1 = new JLabel();
	private JComboBox enumComboBox = new JComboBox();
	private BorderLayout borderLayout3 = new BorderLayout();
	private JTextArea jTextArea2 = new JTextArea();
	
	private JPanel jPanel3 = new JPanel();
	private JScrollPane jScrollPane2 = new JScrollPane();
	private EUTableModel euTableModel = new EUTableModel();
	private JTable euTable = new SortingListTable(euTableModel,
		new int[] { 20, 30, 25, 25 });
	private JButton addEUButton = new JButton();
	private JButton editEUButton = new JButton();
	private JButton deleteEUButton = new JButton();
	private JButton undoDeleteEnumValButton = new JButton();
	private GridBagLayout gridBagLayout1 = new GridBagLayout();
	private JButton undoDeleteEUButton = new JButton();
	private GridBagLayout gridBagLayout2 = new GridBagLayout();
	private BorderLayout borderLayout4 = new BorderLayout();
	private JTextArea jTextArea3 = new JTextArea();
	
	private JPanel jPanel4 = new JPanel();
	private JScrollPane jScrollPane3 = new JScrollPane();
	private EUCnvTableModel ucTableModel = new EUCnvTableModel();
	private JTable ucTable = new SortingListTable(ucTableModel,
		new int[] {17, 17, 18, 8, 8, 8, 8, 8, 8 });
	private JButton addEUCnvtButton = new JButton();
	private JButton editEUCnvtButton = new JButton();
	private JButton deleteEUCnvtButton = new JButton();
	private JButton undoDelEuCnvtButton = new JButton();
	private GridBagLayout gridBagLayout3 = new GridBagLayout();
	private Border border4;
	
	private DTEquivTableModel dteTableModel = new DTEquivTableModel();
	private JTable dteTable = new SortingListTable(dteTableModel,null);
	private JButton addDTEButton = new JButton();
	private JButton editDTEButton = new JButton();
	private JButton deleteDTEButton = new JButton();
	private JButton undoDeleteDTEButton = new JButton();
	private Border border5;
	
	private Border border6;
	private Border border7;

	//================================================
	private boolean enumsChanged = false;
	private boolean unitsChanged = false;
	private boolean convertersChanged = false;
	private boolean dtsChanged = false;
	private boolean seasonsChanged = false;
	private EnumValue deletedEnumValue = null;
	private EngineeringUnit deletedEU = null;
	private UnitConverterDb deletedConverter = null;
	private String []deletedDte = null;

	private SeasonListTableModel seasonListTableModel = new SeasonListTableModel();
	private SortingListTable seasonsTable = new SortingListTable(seasonListTableModel,
		SeasonListTableModel.colWidths);

	/**
	 * No args constructor for JBuilder.
	 */
	public RefListFrame()
	{
		enableEvents(AWTEvent.WINDOW_EVENT_MASK);
		try 
		{
			jbInit();
			initControls();
		}
		catch(Exception e) {
			e.printStackTrace();
		}

		// Default operation is to do nothing when user hits 'X' in upper
		// right to close the window. We will catch the closing event and
		// do the same thing as if user had hit File - Exit.
		setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		addWindowListener(
			new WindowAdapter()
			{
				public void windowClosing(WindowEvent e)
				{
      				jMenuFileExit_actionPerformed(null);
				}
			});
	}

	/**
	 * Initializes the controls in the frames.
	 * Calls the init methods in other GUI objects, table models, etc.
	 */
	private void initControls()
	{
		ArrayList v = new ArrayList();
		for(Iterator enumIt = Database.getDb().enumList.iterator();
			enumIt.hasNext(); )
		{
			decodes.db.DbEnum en = enumIt.next();
			if (en.enumName.equalsIgnoreCase("EquationScope")
			 || en.enumName.equalsIgnoreCase("DataOrder")
			 || en.enumName.equalsIgnoreCase("UnitFamily")
			 || en.enumName.equalsIgnoreCase("LookupAlgorithm")
			 || en.enumName.equalsIgnoreCase("RecordingMode")
			 || en.enumName.equalsIgnoreCase("EquipmentType")
			 || en.enumName.equalsIgnoreCase("Season"))
				continue;
			String s = TextUtil.capsExpand(en.enumName);
			v.add(s);
		}
		Collections.sort(v);
		for(int i=0; i 0)
				{
					String std = dteTableModel.getColumnName(i);
					DataType ndt = DataType.getDataType(std, v);
					if (lastDT != null)
						lastDT.assertEquivalence(ndt);
					lastDT = ndt;
				}
			}
			dteTableModel.rebuild();
			dteTableModel.fireTableDataChanged();
		}
		dtsChanged = true;
		deletedDte = null;
		undoDeleteDTEButton.setEnabled(false);
	}

	/**
	 * Deletes the selected data type equivalence and adds it to the undo buffer.
	 * Enables the undo button.
	 * @param e ActionEvent
	 */
	void deleteDTEButton_actionPerformed(ActionEvent e)
	{
		int row = dteTable.getSelectedRow();
		if (row == -1)
		{
			showError(labels.getString("RefListFrame.selectRowDeleteInfo"));
			return;
		}
		deletedDte = (String[])dteTableModel.getRowObject(row);
		DataTypeSet dts = Database.getDb().dataTypeSet;
		for(int i=0; i 0)
			{
				String std = dteTableModel.getColumnName(i);
				DataType dt = dts.get(std, v);
				if (dt != null)
					dt.deAssertEquivalence();
			}
		}
		undoDeleteDTEButton.setEnabled(true);
		dteTableModel.rebuild();
		dteTableModel.fireTableDataChanged();
		dtsChanged = true;
	}

	/**
	 * Called when save to DB menu item selected.
	 * @param e ActionEvent
	 */
	void mi_saveToDb_actionPerformed(ActionEvent e)
	{
		Database db = Database.getDb();

		String what = "";
		try
		{
			if (seasonsChanged)
			{
				seasonListTableModel.storeBackToEnum();
				enumsChanged = true;
			}
			if (enumsChanged)
			{
				what = "Enumerations";
				db.enumList.write();
				enumsChanged = seasonsChanged = false;
			}
			if (unitsChanged || convertersChanged)
			{
				what = "Engineering Units";
				db.engineeringUnitList.write();
				unitsChanged = convertersChanged = false;
			}
			if (dtsChanged)
			{
				what = "Data Types";
				db.dataTypeSet.write();
				dtsChanged = false;
			}
			
			JOptionPane.showConfirmDialog(this, labels.getString("RefListFrame.changesWritten"),
				"Info", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
		}
		catch(DatabaseException ex)
		{
			showError(LoadResourceBundle.sprintf(labels.getString(
					"RefListFrame.writingErr"),what) + ex);
			ex.printStackTrace();
		}
	}

	/**
	  Launches the passed modal dialog at a reasonable position on the screen.
	  @param dlg the dialog.
	*/
	private void launchDialog(JDialog dlg)
	{
		dlg.setModal(true);
		dlg.validate();
		dlg.setLocationRelativeTo(this);
		dlg.setVisible(true);
	}

	/**
	 * Shows an error message in a JOptionPane and prints it to stderr.
	 * @param msg the error message.
	 */
	public void showError(String msg)
	{
		System.err.println(msg);
		JOptionPane.showMessageDialog(this,
			AsciiUtil.wrapString(msg, 60), "Error!", JOptionPane.ERROR_MESSAGE);
	}
}
class RefListFrame_jMenuFileExit_ActionAdapter implements ActionListener {
	RefListFrame adaptee;

	RefListFrame_jMenuFileExit_ActionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.jMenuFileExit_actionPerformed(e);
	}
}

class RefListFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
	RefListFrame adaptee;

	RefListFrame_jMenuHelpAbout_ActionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.jMenuHelpAbout_actionPerformed(e);
	}
}

class RefListFrame_enumComboBox_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_enumComboBox_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.enumComboBox_actionPerformed(e);
	}
}

class RefListFrame_addEUButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_addEUButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.addEUButton_actionPerformed(e);
	}
}

class RefListFrame_addEnumValButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_addEnumValButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.addEnumValButton_actionPerformed(e);
	}
}

class RefListFrame_editEnumValButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_editEnumValButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.editEnumValButton_actionPerformed(e);
	}
}

class RefListFrame_deleteEnumValButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_deleteEnumValButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.deleteEnumValButton_actionPerformed(e);
	}
}

class RefListFrame_undoDeleteEnumValButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_undoDeleteEnumValButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.undoDeleteEnumValButton_actionPerformed(e);
	}
}

class RefListFrame_selectEnumValDefaultButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_selectEnumValDefaultButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.selectEnumValDefaultButton_actionPerformed(e);
	}
}

class RefListFrame_upEnumValButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_upEnumValButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.upEnumValButton_actionPerformed(e);
	}
}

class RefListFrame_downEnumValButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_downEnumValButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.downEnumValButton_actionPerformed(e);
	}
}

class RefListFrame_editEUButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_editEUButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.editEUButton_actionPerformed(e);
	}
}

class RefListFrame_deleteEUButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_deleteEUButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.deleteEUButton_actionPerformed(e);
	}
}

class RefListFrame_undoDeleteEUButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_undoDeleteEUButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.undoDeleteEUButton_actionPerformed(e);
	}
}

class RefListFrame_addEUCnvtButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_addEUCnvtButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.addEUCnvtButton_actionPerformed(e);
	}
}

class RefListFrame_editEUCnvtButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_editEUCnvtButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.editEUCnvtButton_actionPerformed(e);
	}
}

class RefListFrame_deleteEUCnvtButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_deleteEUCnvtButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.deleteEUCnvtButton_actionPerformed(e);
	}
}

class RefListFrame_undoDelEuCnvtButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_undoDelEuCnvtButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.undoDelEuCnvtButton_actionPerformed(e);
	}
}

class RefListFrame_addDTEButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_addDTEButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.addDTEButton_actionPerformed(e);
	}
}

class RefListFrame_editDTEButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_editDTEButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.editDTEButton_actionPerformed(e);
	}
}

class RefListFrame_undoDeleteDTEButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_undoDeleteDTEButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.undoDeleteDTEButton_actionPerformed(e);
	}
}

class RefListFrame_deleteDTEButton_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_deleteDTEButton_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.deleteDTEButton_actionPerformed(e);
	}
}

class RefListFrame_mi_saveToDb_actionAdapter implements java.awt.event.ActionListener {
	RefListFrame adaptee;

	RefListFrame_mi_saveToDb_actionAdapter(RefListFrame adaptee) {
		this.adaptee = adaptee;
	}
	public void actionPerformed(ActionEvent e) {
		adaptee.mi_saveToDb_actionPerformed(e);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy