/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.io;
import java.io.File;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import org.apache.log4j.Logger;
/**
* The Frame containing the import data functionality. The concrete
* implementation panel must be set via the setImportPanel
* method.
*
* @author Markus Kraetzig
*/
public class ImportDataFrame extends JInternalFrame {
private static final Logger log = Logger.getLogger(ImportDataFrame.class);
private AbstractImportPanel importPanel = null;
private JPanel ivjContentPane = null;
/**
* OpenFrame constructor comment.
*/
public ImportDataFrame() {
super();
initialize();
}
/**
* Initiates importing data. It calls the importData method
* of the underlying AbstractImportPanel.
*
* @return true if import was successful
* @throws IllegalStateException
* if no import panel has been set before
*
*/
public boolean importData() {
if (importPanel == null)
throw new IllegalStateException("No import panel set.");
return importPanel.importData();
}
/**
* Initiates importing data for athe given file. It calls the
* importData method of the underlying
* AbstractImportPanel.
*
* @param importFile
* the file to read data from
* @return true if import was successful
* @throws IllegalStateException
* if no import panel has been set before
*/
public boolean importData(File importFile) {
if (importPanel == null)
throw new IllegalStateException("No import panel set.");
return importPanel.importData(importFile);
}
/**
* Return the ContentPane property value.
*
* @return javax.swing.JPanel
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getIvjContentPane() {
if (ivjContentPane == null) {
try {
ivjContentPane = new javax.swing.JPanel();
ivjContentPane.setName("InternalFrameContentPane");
ivjContentPane.setLayout(new javax.swing.BoxLayout(
getIvjContentPane(), javax.swing.BoxLayout.X_AXIS));
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjContentPane;
}
/**
* Called whenever the part throws an exception.
*
* @param exception
* Exception
*/
private void handleException(Throwable exception) {
log.error("Unhandled Exception", exception);
}
/**
* Initialize the class.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
try {
// user code begin {1}
// user code end
setClosable(true);
setResizable(true);
setMaximizable(true);
setIconifiable(true);
setName("OpenFrame");
setSize(600, 400);
setMinimumSize(new java.awt.Dimension(600, 400));
setTitle("Import Dataset");
setContentPane(getIvjContentPane());
} catch (Throwable ivjExc) {
handleException(ivjExc);
}
// user code begin {2}
URL url = getClass().getResource("/images/import.gif");
if (url != null)
setFrameIcon(new ImageIcon(url));
// user code end
}
/**
* Sets the panel implementing the import functionality.
*
* @param panel
* the concrete import GUI
* @throws IllegalArgumentException
* if (panel == null)
*/
public void setImportPanel(AbstractImportPanel panel) {
if (panel == null)
throw new IllegalArgumentException("Panel was null.");
importPanel = panel;
getIvjContentPane().add(importPanel, importPanel.getName());
}
}
Ads help maintain this website.