
admin.astor.tools.WideSearchDialog 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.tools;
import admin.astor.Astor;
import fr.esrf.Tango.DevFailed;
import fr.esrf.TangoDs.Except;
import fr.esrf.tangoatk.widget.util.ATKGraphicsUtils;
import fr.esrf.tangoatk.widget.util.ErrorPane;
import javax.swing.*;
import java.awt.*;
//===============================================================
/**
* JDialog Class to display info
*
* @author Pascal Verdier
*/
//===============================================================
public class WideSearchDialog extends JDialog {
private JFrame parent;
private JScrollPane scrollPane;
//===============================================================
/*
* Creates new form WideSearchDialog
*/
//===============================================================
public WideSearchDialog(JFrame parent) {
super(parent, false);
this.parent = parent;
initComponents();
initOwnComponents();
pack();
ATKGraphicsUtils.centerDialog(this);
}
//===============================================================
//===============================================================
private void initOwnComponents() {
// Build scroll pane to tree
scrollPane = new JScrollPane();
scrollPane.setPreferredSize(new Dimension(350, 400));
getContentPane().add(scrollPane, BorderLayout.CENTER);
warningTxt.setVisible(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.
*/
//===============================================================
// //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
javax.swing.JPanel jPanel1 = new javax.swing.JPanel();
javax.swing.JButton cancelBtn = new javax.swing.JButton();
javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
javax.swing.JLabel titleLabel = new javax.swing.JLabel();
wildcardTxt = new javax.swing.JTextField();
warningTxt = new javax.swing.JTextArea();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
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);
jPanel2.setLayout(new java.awt.GridBagLayout());
titleLabel.setFont(new java.awt.Font("Lucida Sans", 1, 14)); // NOI18N
titleLabel.setText("Search item : ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
jPanel2.add(titleLabel, gridBagConstraints);
wildcardTxt.setColumns(20);
wildcardTxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
wildcardTxtActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
jPanel2.add(wildcardTxt, gridBagConstraints);
warningTxt.setColumns(35);
warningTxt.setFont(new java.awt.Font("Dialog", 1, 12));
warningTxt.setRows(2);
warningTxt.setText("WARNING:\n Command missing. TANGO Database server is not up to date !");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(15, 0, 15, 0);
jPanel2.add(warningTxt, gridBagConstraints);
getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);
pack();
}// //GEN-END:initComponents
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
doClose();
}//GEN-LAST:event_cancelBtnActionPerformed
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
doClose();
}//GEN-LAST:event_closeDialog
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void wildcardTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wildcardTxtActionPerformed
try {
String wildcard = wildcardTxt.getText();
if (wildcard.length() == 0 || wildcard.equals("*"))
Except.throw_exception("BAD_PARAM",
"Filter is empty !",
"wildcardTxt.getText()");
if (!wildcard.startsWith("*"))
wildcard = "*" + wildcard;
if (!wildcard.endsWith("*"))
wildcard = wildcard + "*";
WideSearchTree tree = new WideSearchTree(this, wildcard);
scrollPane.setViewportView(tree);
} catch (DevFailed e) {
ErrorPane.showErrorMessage(parent, null, e);
}
}//GEN-LAST:event_wildcardTxtActionPerformed
//===============================================================
//===============================================================
void displayHostPanel(String hostname) {
if (parent instanceof Astor)
((Astor) parent).tree.displayHostInfoDialog(hostname);
}
//===============================================================
//===============================================================
void setWarning() {
warningTxt.setVisible(true);
pack();
}
//===============================================================
/**
* Closes the dialog
*/
//===============================================================
private void doClose() {
if (parent.getWidth() > 0) {
setVisible(false);
dispose();
} else
System.exit(0);
}
//===============================================================
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextArea warningTxt;
private javax.swing.JTextField wildcardTxt;
// End of variables declaration//GEN-END:variables
//===============================================================
//===============================================================
/**
* @param args the command line arguments
*/
//===============================================================
public static void main(String args[]) {
new WideSearchDialog(new javax.swing.JFrame()).setVisible(true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy