📄 roletypeparametersconfiguration.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.
*/
/*
* RoleTypeParametersConfiguration.java - 3/07/06
*/
package issrg.editor2.configurations;
import issrg.editor2.OIDinputTextField;
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.FocusEvent;
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 RoleTypeParametersConfiguration 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 oidLabel, typeLabel, dataTypeLabel;
/**
* TextFields which refer to the user's input.
*/
private OIDinputTextField oidTextField;
private JTextField typeTextField;
/**
* Drop Down List that allows users to select the data Type for the RoleType.
*/
private JComboBox dataTypeField;
/**
* A description of what the dialog does (to fill up space).
*/
private JTextArea descriptionText;
/**
* Loads the Resource Strings and Labels for everything to display correctly.
*/
ResourceBundle rbl = ResourceBundle.getBundle("issrg/editor2/PEComponent_i18n");
String oidLabelCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Label_OID"); //contains OID
String typeLabelCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Label_Type"); //contains Type
String dataTypeLabelCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Label_Data_Type"); //contains Data Type
String westBorderCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Border_West"); //contains Enter Role Type Details
String eastBorderCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Border_East"); //contains Available Role Types
String textBorderCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Border_TextArea"); //contains Description
String textCaption = rbl.getString("RoleType_Parameters_ConfigDialog_TextArea_Contents");
String addButtonCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Button_Add"); //contains Add Type
String delButtonCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Button_Delete"); //contains Delete Type
String repButtonCaption = rbl.getString("RoleType_Parameters_ConfigDialog_Button_Replace"); //contains Replace
String errorHeader = rbl.getString("ErrorHeader"); //contains Error!
String infoHeader = rbl.getString("InfoHeader"); //contains Info!
String roleTypesParamsConfigError1 = rbl.getString("RoleType_Parameters_ConfigDialog_ErrorMSG1"); //contains Name or Object ID fields cannot be left empty.
String roleTypesParamsConfigError2 = rbl.getString("RoleType_Parameters_ConfigDialog_ErrorMSG2"); //contains Role Type already exists.
String roleTypesParamsConfigError4 = rbl.getString("RoleType_Parameters_ConfigDialog_ErrorMSG3"); //contains Data Type Cannot be empty.
String roleTypesParamsConfigError3 = rbl.getString("oidTF_LOST_FOCUS_MSG_ERROR"); //contains Invalid OID Format.
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 RoleTypeParametersConfiguration */
public RoleTypeParametersConfiguration(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
westPanel = new JPanel();
envParamConfigPanel = new JPanel();
//---------------------------------
//initialization of the JLabels
oidLabel = new JLabel(oidLabelCaption);
typeLabel = new JLabel(typeLabelCaption);
dataTypeLabel = new JLabel(dataTypeLabelCaption);
//-----------------------------
//initialization of the JTextFields
oidTextField = new OIDinputTextField();
typeTextField = 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
oidTextField.addKeyListener(this);
typeTextField.addKeyListener(this);
oidTextField.addActionListener(this);
oidTextField.setActionCommand("oid_tf");
typeTextField.addActionListener(this);
typeTextField.setActionCommand("type_tf");
//---------------------------------
//initialization of the other Components
descriptionText = new JTextArea(textCaption);
descriptionText.setPreferredSize(new Dimension(250, 130));
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(typeLabel, westPanel, 0, 0, 1, 1, GridBagConstraints.LINE_END, 0, 0, GridBagConstraints.NONE);
addComponent(typeTextField, westPanel, 0, 1, 1, 1, GridBagConstraints.LINE_END, 1, 0, GridBagConstraints.HORIZONTAL);
constraints.insets = new Insets(5,5,5,5);
addComponent(oidLabel, westPanel, 1, 0, 1, 1, GridBagConstraints.LINE_END, 0, 0, GridBagConstraints.NONE);
addComponent(oidTextField, westPanel, 1, 1, 1, 1, GridBagConstraints.LINE_END, 1, 0, GridBagConstraints.HORIZONTAL);
constraints.insets = new Insets(0,5,0,5);
addComponent(dataTypeLabel, westPanel, 2, 0, 1, 1, GridBagConstraints.LINE_END, 0, 0, GridBagConstraints.NONE);
addComponent(dataTypeField, westPanel, 2, 1, 1, 1, GridBagConstraints.LINE_END, 1, 0, GridBagConstraints.HORIZONTAL);
//---------------------------------
//Create the final panel
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
* 'pe.cfg' file.
*/
public boolean isInPolicy(Element childToCheck)
{
NodeList nlist1 = ((Element)getParentNode()).getElementsByTagName("RoleSpec");
for (int i = 0; i < nlist.getLength() ; i++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -