/*
* PdfDialog.java
*
* Created on 8. August 2007, 16:34
*/
package de.unisiegen.tpml.ui.netbeans;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
/**
*
* @author cfehling
*/
public class TexDialog extends javax.swing.JDialog {
/** Creates new form PdfDialog */
public TexDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jSeparator1 = new javax.swing.JSeparator();
overlappingLabel = new javax.swing.JLabel();
filechooser = new javax.swing.JFileChooser();
overlappingTextField = new javax.swing.JTextField();
allCheckBox = new javax.swing.JCheckBox();
pageCountLabel = new javax.swing.JLabel();
pageCountTextField = new javax.swing.JTextField();
overlappingEntity = new javax.swing.JLabel();
getContentPane().setLayout(new java.awt.GridBagLayout());
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("LaTeX Export");
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
TexDiealogCloseActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(jSeparator1, gridBagConstraints);
overlappingLabel.setText("Overlapping:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipady = 5;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(overlappingLabel, gridBagConstraints);
filechooser.setDialogTitle("LaTeX Export");
filechooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
filechooser.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
filechooserActionPerformed(evt);
}
});
filechooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
filechooserPropertyChange(evt);
}
});
filechooser.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
filechooserMouseClicked(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 6;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(filechooser, gridBagConstraints);
overlappingTextField.setText("0");
overlappingTextField.setToolTipText("please enter the overlapping in mm");
overlappingTextField.setPreferredSize(new java.awt.Dimension(25, 19));
overlappingTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
overlappingTextFieldActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
getContentPane().add(overlappingTextField, gridBagConstraints);
allCheckBox.setSelected(true);
allCheckBox.setText("Export all");
allCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
allCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 5;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 0);
getContentPane().add(allCheckBox, gridBagConstraints);
pageCountLabel.setText("Pagecount:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 10);
getContentPane().add(pageCountLabel, gridBagConstraints);
pageCountTextField.setText("5");
pageCountTextField.setPreferredSize(new java.awt.Dimension(25, 19));
pageCountTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pageCountTextFieldActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 10);
getContentPane().add(pageCountTextField, gridBagConstraints);
overlappingEntity.setText("mm");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 20);
getContentPane().add(overlappingEntity, gridBagConstraints);
pack();
}// </editor-fold>//GEN-END:initComponents
private void TexDiealogCloseActionPerformed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_TexDiealogCloseActionPerformed
this.cancelled=true;
return;
}//GEN-LAST:event_TexDiealogCloseActionPerformed
private void pageCountTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pageCountTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_pageCountTextFieldActionPerformed
private void overlappingTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_overlappingTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_overlappingTextFieldActionPerformed
private void filechooserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_filechooserMouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_filechooserMouseClicked
private void filechooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_filechooserPropertyChange
// TODO add your handling code here:
}//GEN-LAST:event_filechooserPropertyChange
private void filechooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filechooserActionPerformed
// TODO add your handling code here:
if (evt.getActionCommand().equals("CancelSelection")){
this.cancelled = true;
this.dispose();
} else
if (evt.getActionCommand().equals("ApproveSelection")){
this.all = allCheckBox.isSelected();
this.overlapping = overlappingTextField.getText();
try{
int test = Integer.parseInt(overlappingTextField.getText());
if (test <0 || test > 50)
{
throw new NumberFormatException();
}
overlappingInt = test;
}
catch (NumberFormatException e)
{
//TODO Multilanguage
JOptionPane.showMessageDialog(this,"The Overlapping-Value must be an integer between 0 and 50!");
return;
}
try {
int test = Integer.parseInt(pageCountTextField.getText());
if (test <0 || test > 13)
{
throw new NumberFormatException();
}
pagecount = test;
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(this,"The pagecount value must be an integer between 1 and 13");
return;
}
this.dispose();
}
}//GEN-LAST:event_filechooserActionPerformed
// Variablendeklaration - nicht modifizieren//GEN-BEGIN:variables
public javax.swing.JCheckBox allCheckBox;
public javax.swing.JFileChooser filechooser;
private javax.swing.JSeparator jSeparator1;
public javax.swing.JLabel overlappingEntity;
public javax.swing.JLabel overlappingLabel;
public javax.swing.JTextField overlappingTextField;
public javax.swing.JLabel pageCountLabel;
public javax.swing.JTextField pageCountTextField;
// Ende der Variablendeklaration//GEN-END:variables
/**
* true if the tpml.tex shohld be indluded
*/
public boolean all;
/**
* true if the dialog is canceld
*/
public boolean cancelled;
public String overlapping;
/**
* the overlapping enterd by the user
*/
public int overlappingInt;
/**
* the pagecount enterd by the user
*/
public int pagecount;
}