/*
 * DetectorJDialog.java
 *
 * Created on Feb 14, 2011, 9:48:28 AM
 */

package org.micromanager.internal.hcwizard;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

/**
 * @author karlhoover
 */
public final class DetectorJDialog extends JDialog {
   private JTextPane detectionTextPane_;

   public boolean cancelRequest() {
      return cancelRequest_;
   }

   public void progressText(final String t) {
      detectionTextPane_.setText(t);
   }

   private boolean cancelRequest_;


   /**
    * Creates new form DetectorJDialog.
    */
   public DetectorJDialog(java.awt.Dialog parent, boolean modal) {
      super(parent, modal);
      initComponents();
      cancelRequest_ = false;
   }

   /**
    * 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="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {

      // Variables declaration - do not modify//GEN-BEGIN:variables
      final JButton cancelButton = new JButton();
      final JScrollPane jScrollPane2 = new JScrollPane();
      detectionTextPane_ = new JTextPane();

      addComponentListener(new java.awt.event.ComponentAdapter() {
         public void componentShown(java.awt.event.ComponentEvent evt) {
            formComponentShown(evt);
         }
      });

      cancelButton.setText("Cancel");
      cancelButton.addActionListener(this::cancelButton_ActionPerformed);

      jScrollPane2.setViewportView(detectionTextPane_);

      GroupLayout layout = new GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addComponent(cancelButton)
                              .addComponent(jScrollPane2, GroupLayout.Alignment.TRAILING,
                                    GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE))
                        .addContainerGap())
      );
      layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 156,
                              GroupLayout.PREFERRED_SIZE)
                        .addGap(17, 17, 17)
                        .addComponent(cancelButton)
                        .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
      );

      pack();
   }

   @SuppressWarnings("checkstyle:MethodName")
   private void cancelButton_ActionPerformed(java.awt.event.ActionEvent evt) {
      System.out.print("cancelButton_ActionPerformed");
      cancelRequest_ = true;
   }

   private void formComponentShown(java.awt.event.ComponentEvent evt) {
      cancelRequest_ = false;
   }

}
