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

📄 permishelpcontent.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* Copyright (c) 2000-2005, University of Salford
* 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. 
*
* Neither the name of the University of Salford nor the names of its 
* contributors may be used to endorse or promote products derived from this 
* software without specific prior written permission. 
*
* 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. 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.
*/

/*
 * PermisHelpContent.java
 *
 * Created on 28 July 2004, 10:04
 */

package issrg.editor.gui;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.ToolTipManager;
import javax.swing.ImageIcon;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JOptionPane;

import java.util.ResourceBundle;

import java.net.URL;
import java.io.IOException;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Component;

import java.util.ResourceBundle;

/**
 * Classname:   PermisHelpContent
 * 
 * Description: A class that generates the help contents
 * 
 *              Version 1.2.4.
 *
 * Copyright (c) the authors April 2004
 *
 * @author      Professor D.W.Chadwick
 *           
 *              U. Mbanaso
 */


public class PermisHelpContent extends javax.swing.JFrame implements TreeSelectionListener {
    private JEditorPane htmlPane;
    private JTree tree;
    private URL helpURL;
    private static boolean DEBUG = false;

    private PermisPolicyEditorMain parent;
   
    /** Creates a new instance of PermisHelpContent */
    public PermisHelpContent(PermisPolicyEditorMain parent) {
        
       
       this.parent = parent;
       initiComponenets();
       this.setSize(627,  497);
       this.setTitle( ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("pol_help_content_title"));
       this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

       this.setResizable(true);
    }
    private void initiComponenets()
    {
         //Create the nodes.
        
        DefaultMutableTreeNode top =
        new DefaultMutableTreeNode(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("pol_help_content_title"));
        createNodes(top);

        //Create a tree that allows one selection at a time.
        tree = new JTree(top);
        tree.getSelectionModel().setSelectionMode
                (TreeSelectionModel.SINGLE_TREE_SELECTION);
         
        //Enable tool tips.
        ToolTipManager.sharedInstance().registerComponent(tree);
        
         ImageIcon parentIcon = createImageIcon("cross.gif");
        if (parentIcon != null) {
            tree.setCellRenderer(new MyRenderer(parentIcon));
        } else {
           // System.err.println("");
        }
        //Set the icon for leaf nodes.
        ImageIcon tutorialIcon = createImageIcon("arrow.gif");
        if (tutorialIcon != null) {
            tree.setCellRenderer(new MyRenderer(tutorialIcon));
        } else {
            //System.err.println("");
        }
        
       

        //Listen for when the selection changes.
        tree.addTreeSelectionListener(this);

        //Create the scroll pane and add the tree to it. 
        JScrollPane treeView = new JScrollPane(tree);
         addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        //Create the HTML viewing pane.
        htmlPane = new JEditorPane();
       htmlPane.addHyperlinkListener(new LinkFollower(htmlPane));

        htmlPane.setEditable(false);
        initHelp();
        JScrollPane htmlView = new JScrollPane(htmlPane);

        //Add the scroll panes to a split pane.
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        splitPane.setTopComponent(treeView);
        splitPane.setBottomComponent(htmlView);

        Dimension minimumSize = new Dimension(200, 50);
        htmlView.setMinimumSize(minimumSize);
        treeView.setMinimumSize(minimumSize);
        splitPane.setDividerLocation(100); // ignored in some releases
                                           //of Swing. bug 4101306
        //workaround for bug 4101306:
        //treeView.setPreferredSize(new Dimension(100, 100)); 

        splitPane.setPreferredSize(new Dimension(500, 500));

        //Add the split pane to this panel.
        getContentPane().add(splitPane, java.awt.BorderLayout.CENTER);

        pack();
      // this.getContentPane().add(splitPane);
    }
    
      public void exitForm(java.awt.event.WindowEvent evt) {
       this.dispose();
    }
     /** Required by TreeSelectionListener interface. */
    public void valueChanged(TreeSelectionEvent e) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                           tree.getLastSelectedPathComponent();

        if (node == null) return;

        Object nodeInfo = node.getUserObject();
        if (node.isLeaf()) {
            PermisHelpContents helpNode = (PermisHelpContents)nodeInfo;
            displayURL(helpNode.helpURL);
            if (DEBUG) {
                System.out.print(helpNode.helpURL + ":  \n    ");
            }
        } else {
            displayURL(helpURL); 
        }
        if (DEBUG) {
            System.out.println(nodeInfo.toString());
        }
    }

    private class PermisHelpContents {
        public String helpTextNode;
        public URL helpURL;

        public PermisHelpContents(String helpNode, String filename) {
            helpTextNode = helpNode;
            helpURL = PermisHelpContent.class.getResource(filename);
            if (helpURL == null) {
                //System.err.println(": "
                                 //  + filename);
            }
        }

        public String toString() {
            return helpTextNode;
        }
    }

    private void initHelp() {
        String s = "introduction.html";

⌨️ 快捷键说明

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