
admin.astor.EditPropertyDialog Maven / Gradle / Ivy
//+======================================================================
// $Source: $
//
// Project: Tango
//
// Description: java source code for Tango manager tool..
//
// $Author$
//
// Copyright (C) : 2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,
// 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$
//
//-======================================================================
package admin.astor;
import java.awt.Window;
import javax.swing.*;
//===============================================================
/**
* Class Description: Basic Dialog Class to display info
*
* @author root
*/
//===============================================================
@SuppressWarnings("WeakerAccess")
public class EditPropertyDialog extends JDialog {
private ServArchitectureDialog.TgProperty retVal = null;
private ServArchitectureDialog.TgProperty prop;
private String initial_value;
//===============================================================
/**
* Creates new form EditPropertyDialog
*/
//===============================================================
public EditPropertyDialog(Window parent, ServArchitectureDialog.TgProperty prop) {
super(parent);
setModal(true);
this.prop = prop;
initComponents();
String title = prop.src + ": " + prop.objectName + "/" + prop.name;
titleLabel.setText(title);
descriptionTxt.setText(prop.desc);
defaultValTxt.setText(
ServArchitectureDialog.OneLine2multiLine(prop.def_value));
dbValTxt.setText(
ServArchitectureDialog.OneLine2multiLine(prop.db_value));
initial_value = dbValTxt.getText();
manageOkBtn();
pack();
setLocationRelativeTo(parent);
}
//===============================================================
/**
* 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 jPanel1 = new javax.swing.JPanel();
okBtn = new javax.swing.JButton();
javax.swing.JButton cancelBtn = new javax.swing.JButton();
javax.swing.JPanel jPanel3 = new javax.swing.JPanel();
javax.swing.JPanel jPanel5 = new javax.swing.JPanel();
javax.swing.JPanel jPanel4 = new javax.swing.JPanel();
javax.swing.JTextField jTextField12 = new javax.swing.JTextField();
javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
defaultValTxt = new javax.swing.JTextArea();
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
javax.swing.JLabel jLabel11 = new javax.swing.JLabel();
javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
titleLabel = new javax.swing.JLabel();
descriptionTxt = new javax.swing.JTextArea();
javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
dbValTxt = new javax.swing.JTextArea();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
okBtn.setText("OK");
okBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okBtnActionPerformed(evt);
}
});
jPanel1.add(okBtn);
cancelBtn.setText("Cancel");
cancelBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelBtnActionPerformed(evt);
}
});
jPanel1.add(cancelBtn);
getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
jPanel3.setLayout(new java.awt.BorderLayout());
jPanel4.setLayout(new java.awt.GridBagLayout());
jTextField12.setEditable(false);
jTextField12.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jTextField12.setText(" ");
jTextField12.setBorder(null);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel4.add(jTextField12, gridBagConstraints);
jLabel2.setText("Default Value : ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 10;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel4.add(jLabel2, gridBagConstraints);
defaultValTxt.setEditable(false);
defaultValTxt.setBackground(new java.awt.Color(204, 204, 204));
defaultValTxt.setColumns(40);
defaultValTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 11;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel4.add(defaultValTxt, gridBagConstraints);
jLabel1.setText(" ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 9;
jPanel4.add(jLabel1, gridBagConstraints);
jLabel11.setText(" ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 19;
jPanel4.add(jLabel11, gridBagConstraints);
jLabel3.setText("Database Value : ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 20;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel4.add(jLabel3, gridBagConstraints);
titleLabel.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
titleLabel.setText("Dialog Title");
jPanel2.add(titleLabel);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
jPanel4.add(jPanel2, gridBagConstraints);
descriptionTxt.setBackground(new java.awt.Color(204, 204, 204));
descriptionTxt.setEditable(false);
descriptionTxt.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 6;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel4.add(descriptionTxt, gridBagConstraints);
jPanel5.add(jPanel4);
jPanel3.add(jPanel5, java.awt.BorderLayout.NORTH);
jScrollPane1.setPreferredSize(new java.awt.Dimension(180, 100));
dbValTxt.setColumns(40);
dbValTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
dbValTxt.setPreferredSize(null);
dbValTxt.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
dbValTxtKeyReleased(evt);
}
});
dbValTxt.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
dbValTxtMouseClicked(evt);
}
});
jScrollPane1.setViewportView(dbValTxt);
jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);
getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);
pack();
}// //GEN-END:initComponents
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void dbValTxtMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dbValTxtMouseClicked
manageOkBtn();
}//GEN-LAST:event_dbValTxtMouseClicked
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void dbValTxtKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dbValTxtKeyReleased
manageOkBtn();
}//GEN-LAST:event_dbValTxtKeyReleased
//===============================================================
//===============================================================
private void manageOkBtn() {
// Set OK radioButton enabled only if value has changed.
String db_val = dbValTxt.getText();
boolean b = !db_val.equals(initial_value);
okBtn.setEnabled(b);
}
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void okBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBtnActionPerformed
String db_val = dbValTxt.getText().trim();
retVal = prop;
if (db_val.length() > 0)
retVal.db_value = ServArchitectureDialog.multiLine2OneLine(db_val);
else
retVal.db_value = null;
doClose();
}//GEN-LAST:event_okBtnActionPerformed
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
doClose();
}//GEN-LAST:event_cancelBtnActionPerformed
//===============================================================
/**
* Closes the dialog
*/
//===============================================================
@SuppressWarnings("UnusedParameters")
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
doClose();
}//GEN-LAST:event_closeDialog
//===============================================================
/**
* Closes the dialog
*/
//===============================================================
private void doClose() {
setVisible(false);
dispose();
}
//===============================================================
//===============================================================
public ServArchitectureDialog.TgProperty showDialog() {
setVisible(true);
return retVal;
}
//===============================================================
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextArea dbValTxt;
private javax.swing.JTextArea defaultValTxt;
private javax.swing.JTextArea descriptionTxt;
private javax.swing.JButton okBtn;
private javax.swing.JLabel titleLabel;
// End of variables declaration//GEN-END:variables
//===============================================================
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy