/*
* 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.r.rintegration.gui;
import org.jax.r.rintegration.PlatformSpecificRFunctions;
import org.jax.r.rintegration.RLaunchConfiguration;
/**
* This frame was mostly generated by the netbeans visual editor 6.0, so be
* careful to respect the comments when editing this class. It may be best
* to make modifications using Netbeans.
* This frame relies on {@link RHomeSelectorPanel} for a lot of the heavy
* lifting.
* @author <A HREF="mailto:keith.sheppard@jax.org">Keith Sheppard</A>
*/
public class RHomeSelectorFrame extends javax.swing.JFrame
{
/**
* every {@link java.io.Serializable} is supposed to have one of these
*/
private static final long serialVersionUID = -8596109379762384136L;
/**
* Holds our reference to the selector panel.
*/
private final RHomeSelectorPanel rHomeSelectorPanel;
/**
* Constructor
* @param rPlatformSpecific
* the install directory structure to use
*/
public RHomeSelectorFrame(
PlatformSpecificRFunctions rPlatformSpecific)
{
// initialize the selector panel since this is used in the netbeans
// designer code (initComponents)
super("Select an R Installation");
this.rHomeSelectorPanel = new RHomeSelectorPanel(
rPlatformSpecific,
true);
this.initComponents();
}
/**
* Cancel the R Home selection
*/
private void cancel()
{
if(this.rHomeSelectorPanel.cancel())
{
this.dispose();
}
}
/**
* Accept the selected R Home after validation.
*/
private void ok()
{
if(this.rHomeSelectorPanel.apply())
{
this.dispose();
}
}
/**
* This method just delegates to
* {@link RHomeSelectorPanel#getSelectedLaunchConfiguration()}
* @return
* the launch configuration
*/
public RLaunchConfiguration getSelectedLaunchConfiguration()
{
return this.rHomeSelectorPanel.getSelectedLaunchConfiguration();
}
/** 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() {
okCancelPanel = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
rHomeSelectorPanelDownCast = this.rHomeSelectorPanel;
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
okCancelPanel.add(okButton);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
okCancelPanel.add(cancelButton);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(okCancelPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
.add(rHomeSelectorPanelDownCast, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(rHomeSelectorPanelDownCast, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(okCancelPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* Respond to an OK pressed event. The signature for this method
* was generated by Netbeans.
* @param evt
* the event
*/
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
this.ok();
}//GEN-LAST:event_okButtonActionPerformed
/**
* Respond to a cancel pressed event. This signature for this method was
* generated by Netbeans.
* @param evt
* the event
*/
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
this.cancel();
}//GEN-LAST:event_cancelButtonActionPerformed
/**
* Cancel R Home selection
* @param evt
* the window close event
*/
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
this.cancel();
}//GEN-LAST:event_formWindowClosing
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JButton okButton;
private javax.swing.JPanel okCancelPanel;
private javax.swing.JPanel rHomeSelectorPanelDownCast;
// End of variables declaration//GEN-END:variables
}