You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
215 lines
8.5 KiB
Java
215 lines
8.5 KiB
Java
/*
|
|
* Copyright (C) 2009-2017 Alistair Neil <info@dazzleships.net>
|
|
*
|
|
* This program 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 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program 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 this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
package client;
|
|
|
|
import lib.Localisation;
|
|
|
|
/**
|
|
*
|
|
* @author Alistair Neil, <info@dazzleships.net>
|
|
*/
|
|
public final class QuickAddDialog extends javax.swing.JDialog {
|
|
|
|
private static final Localisation LOCAL = new Localisation("resources/MessagesBundle");
|
|
public static final int CANCEL = 0;
|
|
public static final int APPLY = 1;
|
|
public static final int RESET = 2;
|
|
|
|
/**
|
|
* Creates a quick add patterns dialog
|
|
*
|
|
* @param parent parent frame
|
|
* @param modal modality
|
|
*/
|
|
public QuickAddDialog(java.awt.Frame parent, boolean modal) {
|
|
super(parent, modal);
|
|
initComponents();
|
|
}
|
|
|
|
/**
|
|
* Set text that appears on the Apply button
|
|
*
|
|
* @param text
|
|
*/
|
|
public void setApplyText(String text) {
|
|
jButtonApply.setText(text);
|
|
}
|
|
|
|
/**
|
|
* Set the test that appears in both fields
|
|
*
|
|
* @param desc
|
|
* @param pattern
|
|
*/
|
|
public void setFields(String desc, String pattern) {
|
|
jTextDescription.setText(desc);
|
|
jTextPattern.setText(pattern);
|
|
}
|
|
|
|
/**
|
|
* Get contents of description field
|
|
*
|
|
* @return String text
|
|
*/
|
|
public String getDescription() {
|
|
return jTextDescription.getText();
|
|
}
|
|
|
|
/**
|
|
* Get contents of the pattern field
|
|
*
|
|
* @return String text
|
|
*/
|
|
public String getPattern() {
|
|
return jTextPattern.getText();
|
|
}
|
|
|
|
/**
|
|
* @return the return status of this dialog - one of RET_OK or RET_CANCEL
|
|
*/
|
|
public int getReturnStatus() {
|
|
return returnStatus;
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
jPanelPreferences = new javax.swing.JPanel();
|
|
jLabel1 = new javax.swing.JLabel();
|
|
jTextDescription = new javax.swing.JTextField();
|
|
jLabel2 = new javax.swing.JLabel();
|
|
jTextPattern = new javax.swing.JTextField();
|
|
jButtonCancel = new javax.swing.JButton();
|
|
jButtonApply = new javax.swing.JButton();
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
|
setTitle(LOCAL.getString("dlg_quickadd_title")); // NOI18N
|
|
setIconImage(null);
|
|
setResizable(false);
|
|
addWindowListener(new java.awt.event.WindowAdapter() {
|
|
public void windowClosing(java.awt.event.WindowEvent evt) {
|
|
closeDialog(evt);
|
|
}
|
|
});
|
|
|
|
jPanelPreferences.setFont(jPanelPreferences.getFont().deriveFont(jPanelPreferences.getFont().getStyle() | java.awt.Font.BOLD));
|
|
|
|
jLabel1.setText(LOCAL.getString("label_quickadd_desc")); // NOI18N
|
|
|
|
jLabel2.setText(LOCAL.getString("label_quickadd_pattern")); // NOI18N
|
|
|
|
jButtonCancel.setText(LOCAL.getString("button_cancel")); // NOI18N
|
|
jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButtonCancelActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jButtonApply.setText(LOCAL.getString("button_addnew")); // NOI18N
|
|
jButtonApply.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jButtonApplyActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
javax.swing.GroupLayout jPanelPreferencesLayout = new javax.swing.GroupLayout(jPanelPreferences);
|
|
jPanelPreferences.setLayout(jPanelPreferencesLayout);
|
|
jPanelPreferencesLayout.setHorizontalGroup(
|
|
jPanelPreferencesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(jPanelPreferencesLayout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addGroup(jPanelPreferencesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addComponent(jLabel1)
|
|
.addComponent(jTextDescription, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
|
|
.addComponent(jLabel2)
|
|
.addComponent(jTextPattern, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
|
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelPreferencesLayout.createSequentialGroup()
|
|
.addComponent(jButtonCancel)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(jButtonApply)))
|
|
.addContainerGap())
|
|
);
|
|
jPanelPreferencesLayout.setVerticalGroup(
|
|
jPanelPreferencesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(jPanelPreferencesLayout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addComponent(jLabel1)
|
|
.addGap(0, 0, 0)
|
|
.addComponent(jTextDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(jLabel2)
|
|
.addGap(0, 0, 0)
|
|
.addComponent(jTextPattern, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addGroup(jPanelPreferencesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jButtonApply)
|
|
.addComponent(jButtonCancel))
|
|
.addContainerGap())
|
|
);
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
getContentPane().setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addComponent(jPanelPreferences, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
);
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addComponent(jPanelPreferences, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
);
|
|
|
|
pack();
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void jButtonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApplyActionPerformed
|
|
doClose(APPLY);
|
|
}//GEN-LAST:event_jButtonApplyActionPerformed
|
|
|
|
private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
|
|
doClose(CANCEL);
|
|
}//GEN-LAST:event_jButtonCancelActionPerformed
|
|
|
|
/**
|
|
* Closes the dialog
|
|
*/
|
|
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
|
|
doClose(CANCEL);
|
|
}//GEN-LAST:event_closeDialog
|
|
|
|
private void doClose(int retStatus) {
|
|
returnStatus = retStatus;
|
|
setVisible(false);
|
|
dispose();
|
|
}
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JButton jButtonApply;
|
|
private javax.swing.JButton jButtonCancel;
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JLabel jLabel2;
|
|
private javax.swing.JPanel jPanelPreferences;
|
|
private javax.swing.JTextField jTextDescription;
|
|
private javax.swing.JTextField jTextPattern;
|
|
// End of variables declaration//GEN-END:variables
|
|
private int returnStatus = CANCEL;
|
|
}
|