/*
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.ts;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import org.apache.log4j.Logger;
import com.jstatcom.component.TopFrameReference;
/**
* Dialog for entering a description for a project, before it is saved to a
* file.
*
* @author Markus Kraetzig
*/
public class TSDescDialog extends JDialog {
private static final Logger log = Logger.getLogger(TSDescDialog.class);
// Reference to the underlying TSList.
private TSList tSList = null;
private boolean canceled = true;
private JPanel ivjJDialogContentPane = null;
private JButton ivjCancel = null;
private JButton ivjClear = null;
private JTextArea ivjDescriptionArea = null;
private JPanel ivjJPanel1 = null;
private JScrollPane ivjJScrollPane1 = null;
private JButton ivjOK = null;
class IvjEventHandler implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (e.getSource() == TSDescDialog.this.getOK())
connEtoC1();
if (e.getSource() == TSDescDialog.this.getClear())
connEtoC2();
if (e.getSource() == TSDescDialog.this.getCancel())
connEtoC3();
};
};
IvjEventHandler ivjEventHandler = new IvjEventHandler();
/**
* TSDescDialog default constructor.
*/
public TSDescDialog() {
super();
initialize();
}
/**
* TSDescDialog constructor.
*
* @param owner
* java.awt.Frame
* @param modal
* boolean
*/
public TSDescDialog(java.awt.Frame owner, boolean modal) {
super(owner, modal);
initialize();
}
/**
* Comment
*/
private void cancel_ActionEvents() {
canceled = true;
setVisible(false);
return;
}
/**
* Comment
*/
private void clear_ActionEvents() {
getDescriptionArea().setText("");
return;
}
/**
* connEtoC1: (OK.action. --> TSDescDialog.oK_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC1() {
try {
// user code begin {1}
// user code end
this.oK_ActionEvents();
// user code begin {2}
// user code end
} catch (Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC2: (Clear.action. --> TSDescDialog.clear_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC2() {
try {
// user code begin {1}
// user code end
this.clear_ActionEvents();
// user code begin {2}
// user code end
} catch (Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* connEtoC3: (Cancel.action. --> TSDescDialog.cancel_ActionEvents()V)
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void connEtoC3() {
try {
// user code begin {1}
// user code end
this.cancel_ActionEvents();
// user code begin {2}
// user code end
} catch (Throwable ivjExc) {
// user code begin {3}
// user code end
handleException(ivjExc);
}
}
/**
* Return the Cancel property value.
*
* @return javax.swing.JButton
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JButton getCancel() {
if (ivjCancel == null) {
try {
ivjCancel = new javax.swing.JButton();
ivjCancel.setName("Cancel");
ivjCancel.setPreferredSize(new java.awt.Dimension(85, 27));
ivjCancel.setText("Cancel");
ivjCancel.setMinimumSize(new java.awt.Dimension(85, 27));
ivjCancel.setMaximumSize(new java.awt.Dimension(85, 27));
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjCancel;
}
/**
* Return the Clear property value.
*
* @return javax.swing.JButton
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JButton getClear() {
if (ivjClear == null) {
try {
ivjClear = new javax.swing.JButton();
ivjClear.setName("Clear");
ivjClear.setText("Clear");
ivjClear.setMaximumSize(new java.awt.Dimension(85, 27));
ivjClear.setPreferredSize(new java.awt.Dimension(85, 27));
ivjClear.setMargin(new java.awt.Insets(2, 2, 2, 2));
ivjClear.setMinimumSize(new java.awt.Dimension(85, 27));
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjClear;
}
/**
* Returns the text entered as description by the user.
*
* @return String
*/
public String getDescription() {
return getDescriptionArea().getText();
}
/**
* Return the DescriptionArea property value.
*
* @return javax.swing.JTextArea
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JTextArea getDescriptionArea() {
if (ivjDescriptionArea == null) {
try {
ivjDescriptionArea = new javax.swing.JTextArea();
ivjDescriptionArea.setName("DescriptionArea");
ivjDescriptionArea.setBounds(0, 0, 447, 197);
ivjDescriptionArea.setMargin(new java.awt.Insets(5, 5, 5, 5));
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjDescriptionArea;
}
/**
* Return the JDialogContentPane property value.
*
* @return javax.swing.JPanel
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getJDialogContentPane() {
if (ivjJDialogContentPane == null) {
try {
ivjJDialogContentPane = new javax.swing.JPanel();
ivjJDialogContentPane.setName("JDialogContentPane");
ivjJDialogContentPane.setLayout(new java.awt.BorderLayout());
getJDialogContentPane().add(getJPanel1(), "South");
getJDialogContentPane().add(getJScrollPane1(), "Center");
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJDialogContentPane;
}
/**
* Return the JPanel1 property value.
*
* @return javax.swing.JPanel
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getJPanel1() {
if (ivjJPanel1 == null) {
try {
ivjJPanel1 = new javax.swing.JPanel();
ivjJPanel1.setName("JPanel1");
ivjJPanel1.setPreferredSize(new java.awt.Dimension(275, 50));
ivjJPanel1.setLayout(getJPanel1FlowLayout());
getJPanel1().add(getOK(), getOK().getName());
getJPanel1().add(getClear(), getClear().getName());
getJPanel1().add(getCancel(), getCancel().getName());
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJPanel1;
}
/**
* Return the JPanel1FlowLayout property value.
*
* @return java.awt.FlowLayout
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private java.awt.FlowLayout getJPanel1FlowLayout() {
java.awt.FlowLayout ivjJPanel1FlowLayout = null;
try {
/* Create part */
ivjJPanel1FlowLayout = new java.awt.FlowLayout();
ivjJPanel1FlowLayout.setVgap(10);
ivjJPanel1FlowLayout.setHgap(20);
} catch (Throwable ivjExc) {
handleException(ivjExc);
}
;
return ivjJPanel1FlowLayout;
}
/**
* Return the JScrollPane1 property value.
*
* @return javax.swing.JScrollPane
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JScrollPane getJScrollPane1() {
if (ivjJScrollPane1 == null) {
try {
ivjJScrollPane1 = new javax.swing.JScrollPane();
ivjJScrollPane1.setName("JScrollPane1");
getJScrollPane1().setViewportView(getDescriptionArea());
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjJScrollPane1;
}
/**
* Return the OK property value.
*
* @return javax.swing.JButton
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JButton getOK() {
if (ivjOK == null) {
try {
ivjOK = new javax.swing.JButton();
ivjOK.setName("OK");
ivjOK.setText("OK");
ivjOK.setMaximumSize(new java.awt.Dimension(85, 27));
ivjOK.setPreferredSize(new java.awt.Dimension(85, 27));
ivjOK.setMinimumSize(new java.awt.Dimension(85, 27));
// user code begin {1}
// user code end
} catch (Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjOK;
}
/**
* Called whenever the part throws an exception.
*
* @param exception
* Exception
*/
private void handleException(Throwable exception) {
log.error("Unhandled Exception", exception);
}
/**
* Initializes connections
*
* @exception Exception
* The exception description.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws Exception {
// user code begin {1}
// user code end
getOK().addActionListener(ivjEventHandler);
getClear().addActionListener(ivjEventHandler);
getCancel().addActionListener(ivjEventHandler);
}
/**
* Initialize the class.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initialize() {
try {
// user code begin {1}
// user code end
setName("TSDescDialog");
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(450, 250);
setTitle("Description of New Dataset");
setContentPane(getJDialogContentPane());
initConnections();
} catch (Throwable ivjExc) {
handleException(ivjExc);
}
// user code begin {2}
// user code end
}
/**
* Returns whether dialog was canceled or not.
*
* @return true if canceled, false if not
* canceled
*/
public boolean isCanceled() {
return canceled;
}
/**
* Comment
*/
private void oK_ActionEvents() {
canceled = false;
setVisible(false);
return;
}
/**
* Sets the descriptive text displayed by this dialog explicitely.
*
* @param desc
* the description to be displayed
*/
public void setDescription(String desc) {
getDescriptionArea().setText(desc);
}
/**
* Sets TSList for this dialog. The selected time series are
* retrieved from the list and the project information is used for the
* initial display.
*
* @param newTimeSeriesList
* the TSList to be referenced
*/
public void setTSList(TSList newTimeSeriesList) {
tSList = newTimeSeriesList;
TS[] sel = tSList.getSelectedTS();
if (sel.length > 0)
getDescriptionArea().setText(sel[0].project().getDescription());
setLocationRelativeTo(TopFrameReference.getTopFrameRef());
canceled = true;
}
}
Ads help maintain this website.