
org.tango.pogo.gui.PreferencesDialog Maven / Gradle / Ivy
//+======================================================================
//
// Project: Tango
//
// Description: Basic Dialog Class to manage prferences.
//
// $Author: verdier $
//
// Copyright (C) : 2004,2005,2006,2007,2008,2009,2009,2010,2011,2012,2013,2014
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This file is part of Tango.
//
// Tango 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.
//
// Tango 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 Tango. If not, see .
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//-======================================================================
package org.tango.pogo.gui;
import fr.esrf.tangoatk.widget.util.ATKGraphicsUtils;
import org.tango.pogo.gui.tools.PogoFileFilter;
import org.tango.pogo.gui.tools.PogoProperty;
import javax.swing.*;
import java.io.File;
//===============================================================
/**
* JDialog Class to display info
*
* @author Pascal Verdier
*/
//===============================================================
public class PreferencesDialog extends JDialog {
//===============================================================
/**
* Creates new form PreferencesDialog
*
* @param parent parent frame object
*/
//===============================================================
public PreferencesDialog(JFrame parent) {
super(parent, true);
initComponents();
reloadBtn.setSelected(PogoProperty.loadPrevious);
if (PogoProperty.contactAddress != null)
mailTxt.setText(PogoProperty.contactAddress);
if (PogoProperty.inheritHome != null)
inheritanceTxt.setText(PogoProperty.inheritHome);
pack();
ATKGraphicsUtils.centerDialog(this);
}
//===============================================================
/**
* 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.
*/
//===============================================================
// //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
javax.swing.JPanel topPanel = new javax.swing.JPanel();
javax.swing.JLabel titleLabel = new javax.swing.JLabel();
javax.swing.JPanel centerPanel = new javax.swing.JPanel();
javax.swing.JLabel inheritanceLbl = new javax.swing.JLabel();
inheritanceTxt = new javax.swing.JTextField();
javax.swing.JButton inheritanceBtn = new javax.swing.JButton();
reloadBtn = new javax.swing.JRadioButton();
javax.swing.JLabel mailLbl = new javax.swing.JLabel();
mailTxt = new javax.swing.JTextField();
javax.swing.JPanel bottomPanel = new javax.swing.JPanel();
javax.swing.JButton okBtn = new javax.swing.JButton();
javax.swing.JButton cancelBtn = new javax.swing.JButton();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
titleLabel.setFont(new java.awt.Font("Dialog", 1, 18));
titleLabel.setText("Pogo Preferences");
topPanel.add(titleLabel);
getContentPane().add(topPanel, java.awt.BorderLayout.NORTH);
centerPanel.setLayout(new java.awt.GridBagLayout());
inheritanceLbl.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
inheritanceLbl.setText("Inheritance root directory :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
centerPanel.add(inheritanceLbl, gridBagConstraints);
inheritanceTxt.setColumns(50);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 0);
centerPanel.add(inheritanceTxt, gridBagConstraints);
inheritanceBtn.setText("...");
inheritanceBtn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
inheritanceBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
inheritanceBtnActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
centerPanel.add(inheritanceBtn, gridBagConstraints);
reloadBtn.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
reloadBtn.setText("Reload project at startup");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
centerPanel.add(reloadBtn, gridBagConstraints);
mailLbl.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
mailLbl.setText("Default contact email :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
centerPanel.add(mailLbl, gridBagConstraints);
mailTxt.setColumns(30);
mailTxt.setFont(new java.awt.Font("Dialog", 1, 12));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
centerPanel.add(mailTxt, gridBagConstraints);
getContentPane().add(centerPanel, java.awt.BorderLayout.CENTER);
okBtn.setText("OK");
okBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okBtnActionPerformed(evt);
}
});
bottomPanel.add(okBtn);
cancelBtn.setText("Cancel");
cancelBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelBtnActionPerformed(evt);
}
});
bottomPanel.add(cancelBtn);
getContentPane().add(bottomPanel, java.awt.BorderLayout.SOUTH);
pack();
}// //GEN-END:initComponents
//===============================================================
//===============================================================
@SuppressWarnings({"UnusedDeclaration"})
private void okBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBtnActionPerformed
PogoProperty.inheritHome = inheritanceTxt.getText();
PogoProperty.contactAddress = mailTxt.getText();
PogoProperty.loadPrevious = (reloadBtn.getSelectedObjects() != null);
PogoProperty.updatePogoRC();
doClose();
}//GEN-LAST:event_okBtnActionPerformed
//===============================================================
//===============================================================
@SuppressWarnings({"UnusedDeclaration"})
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
doClose();
}//GEN-LAST:event_cancelBtnActionPerformed
//===============================================================
//===============================================================
@SuppressWarnings({"UnusedDeclaration"})
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
doClose();
}//GEN-LAST:event_closeDialog
//===============================================================
//===============================================================
@SuppressWarnings({"UnusedDeclaration"})
private void inheritanceBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inheritanceBtnActionPerformed
JFileChooser chooser = new JFileChooser(inheritanceTxt.getText());
chooser.addChoosableFileFilter(new PogoFileFilter("", "Directory"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int retval = chooser.showDialog(this, "Target Dir.");
if (retval == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
if (file != null)
if (file.isDirectory()) {
inheritanceTxt.setText(file.getAbsolutePath());
}
}
inheritanceTxt.requestFocus();
}//GEN-LAST:event_inheritanceBtnActionPerformed
//===============================================================
/**
* Closes the dialog
*/
//===============================================================
private void doClose() {
setVisible(false);
dispose();
}
//===============================================================
//===============================================================
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField inheritanceTxt;
private javax.swing.JTextField mailTxt;
private javax.swing.JRadioButton reloadBtn;
// End of variables declaration//GEN-END:variables
//===============================================================
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy