/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* saveFrame.java
*
* Created on Jul 14, 2011, 4:30:44 PM
*/
package org.clothocad.tool.primerdesigner;
import java.util.ArrayList;
import org.clothocore.api.core.Collector;
import org.clothocore.api.data.ObjLink;
import org.clothocore.api.data.ObjType;
/**
*
* @author jenhan
*/
public class SaveFrame extends javax.swing.JFrame {
/** Creates new form saveFrame */
public SaveFrame() {
initComponents();
}
SaveFrame(ArrayList<String> fwd, ArrayList<String> rev, PrimerDesignController pdc) {
initComponents();
statusLabel.setText("Waiting");
_controller = pdc;
_fwdSequences = fwd;
_revSequences = rev;
ArrayList<ObjLink> colLinks = Collector.getAllLinksOf(ObjType.COLLECTION);
collectionComboBox.removeAllItems();
for (ObjLink ol : colLinks) {
collectionComboBox.addItem(ol.name);
}
}
/** 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("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
collectionComboBox = new javax.swing.JComboBox();
nameBaseField = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
saveButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
statusLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.title")); // NOI18N
collectionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
nameBaseField.setText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.nameBaseField.text")); // NOI18N
nameBaseField.setToolTipText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.nameBaseField.toolTipText")); // NOI18N
jLabel1.setText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.jLabel1.text")); // NOI18N
jLabel1.setToolTipText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.jLabel1.toolTipText")); // NOI18N
jLabel2.setText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.jLabel2.text")); // NOI18N
saveButton.setText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.saveButton.text")); // NOI18N
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
cancelButton.setText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.cancelButton.text")); // NOI18N
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
statusLabel.setText(org.openide.util.NbBundle.getMessage(SaveFrame.class, "SaveFrame.statusLabel.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(nameBaseField, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
.addComponent(collectionComboBox, 0, 183, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(nameBaseField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(collectionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jLabel2)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(saveButton)
.addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
String collectionName = (String) collectionComboBox.getSelectedItem();
String nameRoot = nameBaseField.getText();
statusLabel.setText("Saving...");
if (collectionName == null) {
statusLabel.setText("Select a collection");
return;
}
if (nameRoot == null) {
statusLabel.setText("Enter a name base");
return;
}
_controller.saveAll(_fwdSequences, _revSequences, nameRoot, collectionName);
this.dispose();
}//GEN-LAST:event_saveButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
this.dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SaveFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JComboBox collectionComboBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField nameBaseField;
private javax.swing.JButton saveButton;
private javax.swing.JLabel statusLabel;
// End of variables declaration//GEN-END:variables
private PrimerDesignController _controller;
private ArrayList<String> _fwdSequences;
private ArrayList<String> _revSequences;
}