decodes.dbeditor.PlatformSelectDialogforSubset 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!
/*
* $Id$
*/
package decodes.dbeditor;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.Vector;
import java.util.ResourceBundle;
import ilex.util.LoadResourceBundle;
import decodes.db.Platform;
import decodes.gui.TopFrame;
/**
Dialog for selecting one or more platforms.
Used by both Db Editor for import/export and for network list building.
*/
public class PlatformSelectDialogforSubset extends JDialog
{
static ResourceBundle genericLabels = DbEditorFrame.getGenericLabels();
static ResourceBundle dbeditLabels = DbEditorFrame.getDbeditLabels();
private JPanel panel1 = new JPanel();
private JPanel jPanel1 = new JPanel();
private FlowLayout flowLayout1 = new FlowLayout();
private JButton selectButton = new JButton();
private JButton cancelButton = new JButton();
private BorderLayout borderLayout1 = new BorderLayout();
private JPanel jPanel2 = new JPanel();
private BorderLayout borderLayout2 = new BorderLayout();
private TitledBorder titledBorder1;
private Border border1;
private PlatformSelectPanelforSubset selectPanel;
private Platform plat;
private boolean cancelled;
/** Constructor. */
public PlatformSelectDialogforSubset(Vector vec)
{
super(TopFrame.instance(),"",true);
selectPanel = new PlatformSelectPanelforSubset(vec);
init();
}
// public PlatformSelectDialogforSubset(JDialog owner)
// {
// super(owner, "", true);
// init();
// }
private void init()
{
plat = null;
try
{
jbInit();
getRootPane().setDefaultButton(selectButton);
pack();
}
catch(Exception ex)
{
ex.printStackTrace();
}
cancelled = false;
}
/** Initialize GUI components. */
void jbInit() throws Exception
{
titledBorder1 =
new TitledBorder(BorderFactory.createLineBorder(
new Color(153, 153, 153),2),
dbeditLabels.getString("PlatformSelectDialog.title"));
border1 = BorderFactory.createCompoundBorder(
titledBorder1,BorderFactory.createEmptyBorder(5,5,5,5));
panel1.setLayout(borderLayout1);
jPanel1.setLayout(flowLayout1);
selectButton.setText(
genericLabels.getString("select"));
selectButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
selectButton_actionPerformed(e);
}
});
cancelButton.setText(
genericLabels.getString("cancel"));
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelButton_actionPerformed(e);
}
});
flowLayout1.setHgap(35);
flowLayout1.setVgap(10);
this.setModal(true);
this.setTitle(
dbeditLabels.getString("PlatformSelectDialog.title"));
jPanel2.setLayout(borderLayout2);
jPanel2.setBorder(border1);
getContentPane().add(panel1);
panel1.add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(selectButton, null);
jPanel1.add(cancelButton, null);
panel1.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(selectPanel, BorderLayout.CENTER);
}
/**
Called when Select button is pressed.
@param e ignored
*/
void selectButton_actionPerformed(ActionEvent e)
{
plat = selectPanel.getSelectedPlatform();
closeDlg();
}
/** Closes dialog. */
void closeDlg()
{
setVisible(false);
dispose();
}
/**
Called when Cancel button is pressed.
@param e ignored
*/
void cancelButton_actionPerformed(ActionEvent e)
{
plat = null;
cancelled = true;
closeDlg();
}
/** @return selected (single) platform, or null if Cancel was pressed. */
public Platform getSelectedPlatform()
{
// Will return null if none selected
return plat;
}
/** @return selected (multiple) platforms, or empty array if none. */
public Platform[] getSelectedPlatforms()
{
if (cancelled)
return new Platform[0];
return selectPanel.getSelectedPlatforms();
}
/**
Called with true if multiple selection is to be allowed.
@param ok true if multiple selection is to be allowed.
*/
public void setMultipleSelection(boolean ok)
{
selectPanel.setMultipleSelection(ok);
}
}