⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifconstraintspanelsimple.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* 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.
*/

/*
 * IfConstraintsPanel.java - 30/05/06
 */
package issrg.editor2.ifcondition;

import issrg.editor2.*;
import issrg.utils.xml.XMLEditor;
import java.awt.BorderLayout;
import java.awt.Dimension;
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.KeyEvent;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * This class will display the appropriate panel for creating the If conditions,
 * be the advanced or the simple panel, and will be displayed in the
 * TargetAccessPolicy tabs when the user clicks the Conditions button.
 *
 * @author Christian Azzopardi
 */
public class IFConstraintsPanelSimple extends JPanel implements ActionListener
{    
    /**
     * The Reference to the XML Editor.
     */
    XMLEditor xmlED;
    
    /**
     *  The index of the tab that is being displayed.
     */
    int index;
    
    /**
     * Grid Bag Constraints, to be able to place the components on the panel,
     * with the required constraints.
     */
    GridBagConstraints constraints;
    
    JPanel simplePanel;
    
    JRadioButton andSelected;
    JRadioButton orSelected;
    
    JButton addConditionsButton;
    
    JFrame owner;
    
    ConditionsTable condTable;
    
    public static final int SIMPLE_PANEL = 0;
    public static final int ADVANCED_PANEL = 1;
    
    /**
     * Loads the String Resources from the '.properties' file.
     */
    ResourceBundle rbl = ResourceBundle.getBundle("issrg/editor2/PEComponent_i18n");
    ResourceBundle rb = ResourceBundle.getBundle("issrg/editor2/PEIFConditions_i18n");
    String errorHeader = rbl.getString("ErrorHeader"); //contains Error!
    String dialogTitle = rbl.getString("IfCondition_Dialog_Title"); //contains Constraints Editor
    String sourceBorderCaption = rbl.getString("IfCondition_Source_Border"); //contains Source
    String varNameBorderCaption = rbl.getString("IfCondition_VarName_Border"); //contains Name
    String varTypeBorderCaption = rbl.getString("IfCondition_VarType_Border"); //contains Type
    String operatorBorderCaption = rbl.getString("IfCondition_Operator_Border"); //contains Operator
    String constantBorderCaption = rbl.getString("IfCondition_Constant_Border"); //contains Constant
    String andRadioButtonCaption = rbl.getString("IfCondition_RadioButton_AND"); //contains All of the Below
    String andRadioButtonCaptionTtip = rbl.getString("IfCondition_RadioButton_AND_Ttip"); //contains Safest Option
    String orRadioButtonCaption = rbl.getString("IfCondition_RadioButton_OR"); //contains At Least One of the Below
    String orRadioButtonCaptionTtip = rbl.getString("IfCondition_RadioButton_OR_Ttip"); //contains More Liberal
    String addRowCaption = rbl.getString("IfCondition_Button_Add_Caption"); //contains Add
    String addButtonTtipCaption = rbl.getString("IfCondition_Button_Add_Ttip"); //contains Adds a new Row to the Constraints
    String selectDateCaption = rbl.getString("TimeDatePanel_DateDialog_Name"); //contains Select Date
    String selectTimeCaption = rbl.getString("TimePanel_Dialog_Name"); //contains Select Time
    String errorMSG1 = rbl.getString("IfCondition_Error_Empty_Field"); //contains Error! Do not Leave Empty Values!

    /**
     * Creates a new instance of the panel that needs to be displayed,
     * according to the parrameters that are passed.
     *
     * @param xmlED         The XML Editor
     * @param index         The index of the tab that is being displayed.
     * @param typeOfPanel   the type of panel to display, be it the Simple or
     *                      Advanced Panel. These could be reffered to by the
     *                      static integeres declared above.
     */
    public IFConstraintsPanelSimple(XMLEditor xmlED, int index, JFrame owner) 
    {
        condTable = new ConditionsTable(xmlED, index, owner);
        this.xmlED = xmlED;
        this.index = index;
        this.owner = owner;
        
        JPanel displayPanel = new JPanel(new GridBagLayout());
        constraints = new GridBagConstraints();
        
        this.setLayout(new BorderLayout());
        this.add(getSimplePanel(), BorderLayout.CENTER);
        refresh();
    }
    
    public JPanel getSimplePanel() 
    {
        simplePanel = new JPanel(new GridBagLayout());
        JPanel oldPanel = condTable.getContentPanel();
        
        orSelected = new JRadioButton(orRadioButtonCaption);
        orSelected.setToolTipText(orRadioButtonCaptionTtip);
        orSelected.setMnemonic(KeyEvent.VK_N);
        andSelected = new JRadioButton(andRadioButtonCaption);
        andSelected.setToolTipText(andRadioButtonCaptionTtip);
        andSelected.setMnemonic(KeyEvent.VK_L);
        
        ButtonGroup group = new ButtonGroup();
        group.add(orSelected);
        group.add(andSelected);
        andSelected.setSelected(true);
        
        JPanel andOrPanel = new JPanel(new GridBagLayout());
        constraints.gridx = 0; constraints.gridy = 0;
        constraints.weightx = 1; constraints.weighty = 1;
        constraints.gridwidth = 1; constraints.gridheight = 1;
        constraints.anchor = GridBagConstraints.CENTER;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.insets = new Insets(0,0,0,0);
        andOrPanel.add(andSelected, constraints);
        
        constraints.gridx = 1; constraints.gridy = 0;
        constraints.weightx = 1; constraints.weighty = 1;
        constraints.gridwidth = 1; constraints.gridheight = 1;
        constraints.anchor = GridBagConstraints.CENTER;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        andOrPanel.add(orSelected, constraints);
        
        constraints.gridx = 0; constraints.gridy = 0;
        constraints.weightx = 1; constraints.weighty = 1;
        constraints.gridwidth = 1; constraints.gridheight = 1;
        constraints.anchor = GridBagConstraints.PAGE_START;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.insets = new Insets(10,0,0,0);
        simplePanel.add(andOrPanel, constraints);
        constraints.insets = new Insets(0,0,0,0);
        
        addConditionsButton = new JButton(addRowCaption);
        addConditionsButton.addActionListener(this);
        addConditionsButton.setActionCommand("ADD_ROW");
        addConditionsButton.setToolTipText(addButtonTtipCaption);
        JPanel addPanel = new JPanel(new GridBagLayout());
        constraints.gridx = 0; constraints.gridy = 0;
        constraints.weightx = 1; constraints.weighty = 1;
        constraints.gridwidth = 1; constraints.gridheight = 1;
        constraints.anchor = GridBagConstraints.CENTER;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        addPanel.add(addConditionsButton, constraints);      
        
        constraints.gridx = 0; constraints.gridy = 1;
        constraints.weightx = 1; constraints.weighty = 1;
        constraints.gridwidth = 1; constraints.gridheight = 1;
        constraints.anchor = GridBagConstraints.LINE_START;
        constraints.fill = GridBagConstraints.NONE;
        constraints.insets = new Insets(10,0,0,0);
        simplePanel.add(addPanel, constraints);
        
        constraints.gridx = 0; constraints.gridy = 2;
        constraints.weightx = 1; constraints.weighty = 1;
        constraints.gridwidth = 2; constraints.gridheight = 1;
        constraints.anchor = GridBagConstraints.CENTER;
        constraints.fill = GridBagConstraints.BOTH;
        oldPanel.setPreferredSize(new Dimension(520,200));
        simplePanel.add(oldPanel, constraints);
        
        return simplePanel;
    }
    
    public void actionPerformed(ActionEvent ae)
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -