
org.tango.pogo.gui.tools.KeyWordsDialog Maven / Gradle / Ivy
The newest version!
//+======================================================================
// $Source: $
//
// Project: Tango
//
// Description: Basic Dialog Class to display info
//
// $Author: pascal_verdier $
//
// Copyright (C) : 2004,2005,2006,2007,2008,2009,2009
// 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: $
//
// $Log: $
//
//-======================================================================
package org.tango.pogo.gui.tools;
import fr.esrf.tangoatk.widget.util.ATKGraphicsUtils;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
//===============================================================
/**
* JDialog Class to display info
*
* @author Pascal Verdier
*/
//===============================================================
@SuppressWarnings("MagicConstant")
public class KeyWordsDialog extends JDialog {
private int returnValue = JOptionPane.OK_OPTION;
//===============================================================
/**
* Creates new form KeyWordsDialog
*/
//===============================================================
public KeyWordsDialog(JDialog parent, List keyWords) {
super(parent, true);
initComponents();
if (keyWords!=null) {
String s = "";
for (String keyWord : keyWords) {
s += keyWord+"\n";
}
keyWordsTextArea.setText(s);
}
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() {
javax.swing.JPanel topPanel = new javax.swing.JPanel();
javax.swing.JLabel titleLabel = new javax.swing.JLabel();
javax.swing.JPanel bottomPanel = new javax.swing.JPanel();
javax.swing.JButton okBtn = new javax.swing.JButton();
javax.swing.JButton cancelBtn = new javax.swing.JButton();
javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
keyWordsTextArea = new javax.swing.JTextArea();
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)); // NOI18N
titleLabel.setText("Words For Search Engine");
topPanel.add(titleLabel);
getContentPane().add(topPanel, java.awt.BorderLayout.NORTH);
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);
keyWordsTextArea.setColumns(30);
keyWordsTextArea.setRows(15);
jScrollPane1.setViewportView(keyWordsTextArea);
getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
pack();
}// //GEN-END:initComponents
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void okBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBtnActionPerformed
returnValue = JOptionPane.OK_OPTION;
doClose();
}//GEN-LAST:event_okBtnActionPerformed
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
returnValue = JOptionPane.CANCEL_OPTION;
doClose();
}//GEN-LAST:event_cancelBtnActionPerformed
//===============================================================
//===============================================================
@SuppressWarnings("UnusedParameters")
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
returnValue = JOptionPane.CANCEL_OPTION;
doClose();
}//GEN-LAST:event_closeDialog
//===============================================================
/**
* Closes the dialog
*/
//===============================================================
private void doClose() {
setVisible(false);
dispose();
}
//===============================================================
//===============================================================
public int showDialog() {
setVisible(true);
return returnValue;
}
//===============================================================
//===============================================================
public List getKeyWords() {
List list = new ArrayList<>();
String lines = keyWordsTextArea.getText();
StringTokenizer stk = new StringTokenizer(lines, "\n");
while (stk.hasMoreElements())
list.add(stk.nextToken());
return list;
}
//===============================================================
//===============================================================
//===============================================================
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextArea keyWordsTextArea;
// End of variables declaration//GEN-END:variables
//===============================================================
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy