view src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPrefsGui.java @ 48:16aa66670d74 database-connection-manager

Fix LTPDA Preferences tooltip
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 19:07:27 +0100
parents 03d92954b939
children
line wrap: on
line source

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LTPDAPrefsGui.java
 *
 * Created on Aug 14, 2010, 12:00:59 PM
 */
package mpipeline.ltpdapreferences;

import java.awt.BorderLayout;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author hewitson
 */
public class LTPDAPrefsGui extends javax.swing.JDialog {

  private LTPDAPreferences prefs;
  private LTPDAPrefsTabPane prefsTabPane;

  /** Creates new form LTPDAPrefsGui */
  public LTPDAPrefsGui(java.awt.Frame parent, boolean modal, LTPDAPreferences prefs) {
    super(parent, modal);
    this.prefs = prefs;
    initComponents();

    // Add preferences tab
    prefsTabPane = new LTPDAPrefsTabPane(this.prefs);
    prefsTabPane.validate();
//    prefsTabPane.setSize(this.getPreferredSize());
    this.mainPanel.setLayout(new BorderLayout());
    this.mainPanel.add(prefsTabPane);
    this.pack();

//    this.prefs.addObserver(this);
  }

  public void addAvailableWindow(String win) {
    prefsTabPane.addAvailableWindow(win);
  }

  public LTPDAPrefsTabPane getPrefsTabPane() {
    return prefsTabPane;
  }

  public LTPDAPreferences getPrefs() {
    return prefs;
  }

  public void setPrefs(LTPDAPreferences prefs) {
    this.prefs = prefs;
  }

  @Override
  protected void finalize() throws Throwable {
//    System.err.println("finalise");
//    prefs = null;
    super.finalize();
  }

  /** 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() {

    mainPanel = new javax.swing.JPanel();
    doneBtn = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("LTPDA Preferences");
    setLocationByPlatform(true);
    setResizable(false);
    addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent evt) {
        formWindowClosing(evt);
      }
    });

    mainPanel.setBorder(null);

    org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
      mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
      .add(0, 612, Short.MAX_VALUE)
    );
    mainPanelLayout.setVerticalGroup(
      mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
      .add(0, 422, Short.MAX_VALUE)
    );

    doneBtn.setText("Done");
    doneBtn.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        doneBtnActionPerformed(evt);
      }
    });

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
        .addContainerGap()
        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
          .add(mainPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .add(doneBtn))
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
        .addContainerGap()
        .add(mainPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
        .add(doneBtn)
        .addContainerGap())
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

  private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

//    System.err.println("Form closing");
    this.dispose();
    try {
      // TODO add your handling code here:
      this.finalize();
    } catch (Throwable ex) {
      Logger.getLogger(LTPDAPrefsGui.class.getName()).log(Level.SEVERE, null, ex);
    }

  }//GEN-LAST:event_formWindowClosing

private void doneBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneBtnActionPerformed

    prefs.writeToDisk();
//    this.dispose();

    this.formWindowClosing(null);
}//GEN-LAST:event_doneBtnActionPerformed

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton doneBtn;
  private javax.swing.JPanel mainPanel;
  // End of variables declaration//GEN-END:variables
//  public void update(Observable o, Object arg) {
//  }
}