📄 envparametersconfiguration.java
字号:
/*
* Copyright (c) 2006, University of Kent
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 1. Neither the name of the University of Kent nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED.
*
* 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
* IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
* SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
* SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
* GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
* TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
* IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
* SERIOUS FAULTS, IN THIS SOFTWARE.
*
* 5. This license is governed, except to the extent that local laws
* necessarily apply, by the laws of England and Wales.
*/
/*
* EnvParametersConfiguration.java - 8/06/06
*/
package issrg.editor2.configurations;
import issrg.utils.xml.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ResourceBundle;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
*
* @author Christian Azzopardi
*/
public class EnvParametersConfiguration extends NodeItemList implements XMLChangeListener, KeyListener, ActionListener, ItemListener
{
/**
* Panels needed to place the component on, and get the GUI right.
*/
private JPanel eastPanel, westPanel, envParamConfigPanel;
/**
* Labels that will accompany the JTextFields, and will inform the user
* what input is required.
*/
private JLabel nameLabel, typeLabel;
/**
* TextFields which refer to the user's input.
*/
private JTextField nameTextField;
/**
* A description of what the dialog does (to fill up space).
*/
private JTextArea descriptionText;
private JComboBox dataTypeField;
/**
* Loads the Resource Strings and Labels for everything to display correctly.
*/
ResourceBundle rbl = ResourceBundle.getBundle("issrg/editor2/PEComponent_i18n");
String nameLabelCaption = rbl.getString("Environment_Parameters_ConfigDialog_Label_Name"); //contains Name
String typeLabelCaption = rbl.getString("Environment_Parameters_ConfigDialog_Label_Type"); //contains Type
String westBorderCaption = rbl.getString("Environment_Parameters_ConfigDialog_Border_West"); //contains Enter Environment Variable Details
String eastBorderCaption = rbl.getString("Environment_Parameters_ConfigDialog_Border_East"); //contains Environment Variables
String textBorderCaption = rbl.getString("Environment_Parameters_ConfigDialog_Border_TextArea"); //contains Description
String textCaption = rbl.getString("Environment_Parameters_ConfigDialog_TextArea_Contents");
String addButtonCaption = rbl.getString("Environment_Parameters_ConfigDialog_Button_Add"); //contains Add VAR
String delButtonCaption = rbl.getString("Environment_Parameters_ConfigDialog_Button_Delete"); //contains Delete VAR
String repButtonCaption = rbl.getString("Environment_Parameters_ConfigDialog_Button_Replace"); //contains Replace
String errorHeader = rbl.getString("ErrorHeader"); //contains Error!
String infoHeader = rbl.getString("InfoHeader"); //contains Info!
String envParamsConfigError1 = rbl.getString("Environment_Parameters_ConfigDialog_ErrorMSG1"); //contains Fields Cannot be left empty.
String envParamsConfigError2 = rbl.getString("Environment_Parameters_ConfigDialog_ErrorMSG2"); //contains Fields Cannot be left empty.
ResourceBundle rb = ResourceBundle.getBundle("issrg/editor2/PEIFConditions_i18n");
String type1 = rb.getString("type1");
String type2 = rb.getString("type2");
String type3 = rb.getString("type3");
String type4 = rb.getString("type4");
String type5 = rb.getString("type5");
String type6 = rb.getString("type6");
String type7 = rb.getString("type7");
/** Creates a new instance of EnvParametersConfiguration */
public EnvParametersConfiguration(XMLEditor that)
{
super(that);
this.setLayout(new BorderLayout());
this.add(getContentPanel(), BorderLayout.CENTER);
setCaption("ADD_BUTTON", addButtonCaption);
setCaption("DELETE_BUTTON", delButtonCaption);
setCaption("REPLACE_BUTTON", repButtonCaption);
}
/**
* Method that creates a GUI Panel with the required fields to create
* and modify an Environment Variable
*
* @return a JPanel with the Display for the Environment Parameters
* configuration.
*/
public JPanel getContentPanel()
{
//initializations of JPanels to use
eastPanel = super.getContentPanel(); //NodeList Panel
eastPanel.setPreferredSize(new Dimension(300,200));
westPanel = new JPanel();
envParamConfigPanel = new JPanel();
//---------------------------------
//initialization of the JLabels
nameLabel = new JLabel();
nameLabel.setText(nameLabelCaption);
typeLabel = new JLabel();
typeLabel.setText(typeLabelCaption);
//-----------------------------
//initialization of the JTextFields
nameTextField = new JTextField(15);
//---------------------------------
//initialization of the JComboBox
dataTypeField = new JComboBox();
dataTypeField.addItemListener(this);
//------populate the ComboBox
dataTypeField.addItem("");
dataTypeField.addItem(type3);
dataTypeField.addItem(type4);
dataTypeField.addItem(type5);
dataTypeField.addItem(type6);
dataTypeField.addItem(type1);
dataTypeField.addItem(type2);
dataTypeField.addItem(type7);
//----------------------------
//setting the KeyListeners & ActionListeners to the JTextFields
nameTextField.addKeyListener(this);
nameTextField.addActionListener(this);
nameTextField.setActionCommand("name_tf");
//---------------------------------
//initialization of the other Components
descriptionText = new JTextArea(textCaption);
descriptionText.setPreferredSize(new Dimension(300, 200));
descriptionText.setFont(new Font("Dialog", 0, 14));
descriptionText.setForeground(Color.BLACK);
descriptionText.setBackground(new Color(236,233,216));
descriptionText.setLineWrap(true);
descriptionText.setWrapStyleWord(true);
descriptionText.setEditable(false);
//---------------------------------
//Setting the Layout Manager
westPanel.setLayout(new GridBagLayout());
envParamConfigPanel.setLayout(new GridBagLayout());
//--------------------------
//Fill in panel for user input.
constraints.insets = new Insets(0,5,0,5);
addComponent(nameLabel, westPanel, 0, 0, 1, 1, GridBagConstraints.LINE_END, 0, 0, GridBagConstraints.NONE);
addComponent(nameTextField, westPanel, 0, 1, 1, 1, GridBagConstraints.LINE_END, 1, 0, GridBagConstraints.HORIZONTAL);
constraints.insets = new Insets(5,5,5,5);
addComponent(typeLabel, westPanel, 1, 0, 1, 1, GridBagConstraints.LINE_END, 0, 0, GridBagConstraints.NONE);
addComponent(dataTypeField, westPanel, 1, 1, 1, 1, GridBagConstraints.LINE_END, 1, 0, GridBagConstraints.HORIZONTAL);
//---------------------------------
//Create the final panel
constraints.insets = new Insets(0,0,0,0);
addComponent(eastPanel, envParamConfigPanel, 0, 1, 1, 3, GridBagConstraints.CENTER, 0.5, 1, GridBagConstraints.BOTH);
eastPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), eastBorderCaption));
addComponent(westPanel, envParamConfigPanel, 1, 0, 1, 1, GridBagConstraints.CENTER, 0.5, 0, GridBagConstraints.HORIZONTAL);
westPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), westBorderCaption));
addComponent(descriptionText, envParamConfigPanel, 2, 0, 1, 1, GridBagConstraints.CENTER, 0, 0, GridBagConstraints.NONE);
descriptionText.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), textBorderCaption));
//----------------------
return envParamConfigPanel;
}
/**
* This method can return true, if the Connection Name variable exists
* already. If The connection does not exist it will return false.
* This is used as a measure so that there will be no double entries.
*
* @param childToCheck The element variable with the connection to check
* if already exists in the LDAP directory already.
*
* @return a boolean which says if a connection name exists or not in the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -