/*
* Copyright (c) 2009 The Jackson Laboratory
*
* This software was developed by Gary Churchill's Lab at The Jackson
* Laboratory (see http://research.jax.org/faculty/churchill).
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jax.qtl.cross.gui;
import javax.help.CSH;
import javax.help.HelpSet;
import javax.help.SecondaryWindow;
import org.jax.qtl.QTL;
import org.jax.qtl.cross.SimulateCrossCommandBuilder;
import org.jax.qtl.cross.SimulateMapCommandBuilder;
import org.jax.qtl.project.QtlProjectManager;
import org.jax.r.RCommand;
import org.jax.r.gui.RCommandEditorAndPreviewPanel;
import org.jax.r.jriutilities.RInterface;
import org.jax.r.jriutilities.RInterfaceFactory;
/**
* Dialog for simulating a genetic map and cross object
* @author <A HREF="mailto:keith.sheppard@jax.org">Keith Sheppard</A>
*/
public class SimulateCrossDialog extends javax.swing.JDialog
{
/**
* every {@link java.io.Serializable} is supposed to have one of these
*/
private static final long serialVersionUID = 7869281080184047259L;
private static final String HELP_ID_STRING = "Simulate_Cross";
private final RCommandEditorAndPreviewPanel editorAndPreviewPanel;
private final AllSimulateCrossPanels allSimulateCrossPanels;
/**
* Constructor
* @param parent
* the parent frame
*/
public SimulateCrossDialog(java.awt.Frame parent)
{
super(parent, true);
this.allSimulateCrossPanels = new AllSimulateCrossPanels(
new SimulateMapCommandBuilder(),
new SimulateCrossCommandBuilder());
this.editorAndPreviewPanel = new RCommandEditorAndPreviewPanel(
this.allSimulateCrossPanels);
this.initComponents();
// initialize the help stuff
HelpSet hs = QTL.getInstance().getMenubar().getHelpSet();
CSH.setHelpIDString(
this.helpButton,
HELP_ID_STRING);
this.helpButton.addActionListener(
new CSH.DisplayHelpFromSource(
hs,
SecondaryWindow.class.getName(),
null));
this.updateControlButtons();
}
/**
* Update the [en/dis]abled status of the control buttons
*/
private void updateControlButtons()
{
this.nextButton.setEnabled(this.allSimulateCrossPanels.isNextValid());
this.backButton.setEnabled(this.allSimulateCrossPanels.isBackValid());
this.finishButton.setEnabled(this.allSimulateCrossPanels.isFinishValid());
}
/**
* Simulate a cross given all of the setting that the user specified
*/
private void simulateCross()
{
RCommand simCrossCommand = this.allSimulateCrossPanels.getCommands()[0];
RInterface rInterface = RInterfaceFactory.getRInterfaceInstance();
rInterface.insertComment("Simulating cross");
rInterface.evaluateCommandNoReturn(simCrossCommand);
QtlProjectManager.getInstance().refreshProjectDataStructures();
QtlProjectManager.getInstance().notifyActiveProjectModified();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("all")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
mainContentPanel = this.editorAndPreviewPanel;
actionPanel = new javax.swing.JPanel();
backButton = new javax.swing.JButton();
nextButton = new javax.swing.JButton();
finishButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
helpButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Simulate Cross");
backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/action/back-16x16.png"))); // NOI18N
backButton.setText("Back");
backButton.setEnabled(false);
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
actionPanel.add(backButton);
nextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/action/forward-16x16.png"))); // NOI18N
nextButton.setText("Next");
nextButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nextButtonActionPerformed(evt);
}
});
actionPanel.add(nextButton);
finishButton.setText("Finish");
finishButton.setEnabled(false);
finishButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
finishButtonActionPerformed(evt);
}
});
actionPanel.add(finishButton);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
actionPanel.add(cancelButton);
helpButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/action/help-16x16.png"))); // NOI18N
helpButton.setText("Help...");
actionPanel.add(helpButton);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(actionPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
.add(mainContentPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(mainContentPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(actionPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
this.allSimulateCrossPanels.back();
this.updateControlButtons();
}//GEN-LAST:event_backButtonActionPerformed
private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextButtonActionPerformed
this.allSimulateCrossPanels.next();
this.updateControlButtons();
}//GEN-LAST:event_nextButtonActionPerformed
private void finishButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_finishButtonActionPerformed
if(this.allSimulateCrossPanels.validateData())
{
this.dispose();
this.simulateCross();
}
}//GEN-LAST:event_finishButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
this.dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel actionPanel;
private javax.swing.JButton backButton;
private javax.swing.JButton cancelButton;
private javax.swing.JButton finishButton;
private javax.swing.JButton helpButton;
private javax.swing.JPanel mainContentPanel;
private javax.swing.JButton nextButton;
// End of variables declaration//GEN-END:variables
}