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

📄 209891c3eab7001a1c27ace50896501e

📁 这是一个用java和xml编写的流媒体服务器管理软件
💻
📖 第 1 页 / 共 3 页
字号:
/*
 * ====================================================================
 * The Vovida Software License, Version 1.0 
 *
 */



package vocal.userEditor;

import vocal.comm.VPPNoSuchFileException;
import vocal.data.AccreditConfigTree;
import vocal.data.DevsTreeType;

import vocal.ui.BlankScreen;
import vocal.ui.DVRClientScreen;
import vocal.ui.EnvScreen;
import vocal.ui.FormPanelScreen;
import vocal.ui.GroupScreen;


import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;


import java.util.Hashtable;
import java.util.Vector;
import java.io.IOException;


import java.awt.BorderLayout;
import java.awt.Component;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;

import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.traversal.NodeFilter;
import org.xml.sax.SAXException;

/**
 * Presents the screen which allows the account data (feature configuration,
 * user info, marshal info) for an end user to be edited. <p>
 * It lays out a series of panels which implement the DataEditor interface to
 * actually perform data input, display and validation.<p>
 * This class is used both from the StandAloneUserEditor when and end user edits
 * his own account and from the Editor when an administrator manages end user
 * accounts. When used from StandAloneUserEditor, setShowAdmin(false) is called
 * and all DataEditors are notified to remove fileds which should only be
 * accessible to an administrator, not the end user.<p>
 */

public class AccreditAdd extends JPanel implements Buttons, EditorModes,DevsTreeType,
        WindowListener
{
  private JPanel tmp_devs_screen = new JPanel();  
  private FormPanelScreen currentScreen = null;
  private int currentNodeType = UNKNOWN;
  private int mode = ADD_NEW_MODE;

  private JPanel buttonPanel;
  private JButton ok;
  private JButton cancel;
  private JButton changePassword;
  private GroupInfo groupInfo;
  private JTabbedPane tabpane;
  
  private int lastButtonClicked = BUTTON_NONE;

  private JDialog passwordScreen = null;
  private PasswordPanel passwordPanel;

  private String groupName;

  private AliasPanel aliases;
  private IdentityInfo identity;
  private MarshalInfo marshal;
  private FeatureAccrCallReturn callReturn;
  
  
  private boolean showAdmin = false;
  private boolean showUser = true;
  
  private PServerAccrInterface psInterfaceacc;
  //private JTree tree;
  private JTree tmp_tree;
  private DefaultTreeModel treeModel;

  //create tree model
  private Document treeDOM;
  private Hashtable nodeMap = new Hashtable();
  /**
   * tree nodes to be expanded at initialization
   */
  AccreditConfigTree tree = new AccreditConfigTree();
  Vector treeNodesToExpand = new Vector();
  
  BlankScreen blankScreen;
  DVRClientScreen dvrScreen;
  GroupScreen groupScreen;
  EnvScreen envScreen;
  private AccreditAdd()
  {
    super();

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    setBorder(new EmptyBorder(5, 5, 5, 5));
  }

  public AccreditAdd(final PServerAccrInterface psInterface,int subnumber)
    throws IOException, VPPNoSuchFileException
  {	  
    this();  
    psInterfaceacc = psInterface;
    //passwordPanel = new PasswordPanel(psInterface.getConnection());

    groupInfo = new GroupInfo();

    add(groupInfo);
    
  
    tabpane = new JTabbedPane();
    for(int i=1;i<=subnumber;i++)
    {
    	switch(i)
    	{
    		case 1:
    			//tabpanel[i].GetOisp();
    			//tabpanel[i].TabString="oisp";
    			//tabpanel[i].TabIcon = null;
    			//tabpanel[i].TabJpanel = new JPanel();
    			//tabpanel[i].TabNote = new String("begin configure");
    			//tabpane.addTab(tabpanel[i].TabString,tabpanel[i].TabIcon,tabpanel[i].TabJpanel,tabpanel[i].TabNote);
    			JPanel tmp = Oisp_Features(); 
    			tabpane.addTab("oisp",null,tmp,"oisp configure");    			
    			break;
    		case 2:
    			//tabpanel[i].GetDevs();
    			//tabpane.addTab(tabpanel[i].TabString,tabpanel[i].TabIcon,tabpanel[i].TabJpanel,tabpanel[i].TabNote);
    			JSplitPane tmp_1 = Devs_Accredit(); 
    			tabpane.addTab("devs",null,tmp_1,"devs configure");
    			break;
    		case 3:
    			break;
    		case 4:
    			break;
    		default:
    			break;
    	}		    	
    }
    add(tabpane);

/*
    try
    {
      String[] featureTypes = psInterface.getFeatureTypes();

      for (int i = 0; i < featureTypes.length; i++)
      {
        if (featureTypes[i].equals("ForwardAllCalls")
            || featureTypes[i].equals("ForwardNoAnswerBusy")
            || featureTypes[i].equals("CallBlocking")
            || featureTypes[i].equals("CallScreening")
            || featureTypes[i].equals("CallReturn")
            || featureTypes[i].equals("CallerIdBlocking"))
        {
          String[] groupNames = psInterface.getFeatureGroups(featureTypes[i]);
          FeatureAccr panel = FeatureAccr.createFeature(featureTypes[i], groupNames,
                  psInterface);
          panel.setShowAdmin(true);
          panel.setShowUser(false);
          if (FeatureAccrCallReturn.class.isInstance(panel))
          {
            callReturn = (FeatureAccrCallReturn) panel;
          }
          else
          {
            add(panel);             
          }
        }
      }

      if (callReturn != null)
      {
        add(callReturn);
      }
    }
    catch (SAXException e)
    {
      throw new IOException("Could not load list of feature types because: \n"
              + e);
    }

*/   
    ok = new JButton("Ok");

    // tool tip gets hidden by frame, so leaving it out
    ok.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        if (isAllDataValid())
        {
          lastButtonClicked = AccreditAdd.BUTTON_OK;

          // get the frame which contains this panel and hide it
          AccreditAdd.this.getTopLevelAncestor().setVisible(false);
        }
      }

    });

    cancel = new JButton("Cancel");

    // tool tip gets hidden by frame, so leaving it out
    cancel.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        lastButtonClicked = AccreditAdd.BUTTON_CANCEL;

        // get the frame which contains this panel and hide it
        AccreditAdd.this.getTopLevelAncestor().setVisible(false);
      }

    });

/*
    changePassword = new JButton("Change Password");

    changePassword.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        if (passwordScreen == null)
        {
          Container parent = UserPanel.this.getTopLevelAncestor();

          if (JDialog.class.isInstance(parent))
          {
            passwordScreen = new JDialog((JDialog) parent, "Change password",
                    false);
          }
          else if (JFrame.class.isInstance(parent))
          {
            passwordScreen = new JDialog((JFrame) parent, "Change password",
                    false);
          }

          passwordScreen.setContentPane(passwordPanel);
          passwordScreen.pack();
          passwordScreen.setModal(true);

          Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

          passwordScreen.setLocation((d.width - passwordScreen.getSize().width)
                  / 2, (d.height - passwordScreen.getSize().height) / 2);
        }

        passwordPanel.setUserId(userName);
        passwordScreen.setVisible(true);
      }

    });
*/
    buttonPanel = new JPanel();

    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    //buttonPanel.setBorder(new TitledBorder("Block Long Distance or 900/976 Outgoing calls"));
    buttonPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
    //buttonPanel.add(changePassword);
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(ok);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.add(cancel);
    add(buttonPanel);
/*
    JPanel tmp_long = new JPanel();
    tmp_long.setLayout(new BoxLayout(tmp_long, BoxLayout.X_AXIS)); 
    tmp_long.setBorder(new TitledBorder("Block Long Distance or 900/976 Outgoing calls"));
   
    //buttonPanel.setBorder(new EmptyBorder(5, 0, 0, 0));
    tmp_long.add(Box.createHorizontalGlue());
    tmp_long.add(cancel);
    add(tmp_long);
*/
    setMode(this.EDIT_EXISTING_MODE);
  }
  
  private void setCurrentScreen(FormPanelScreen newScreen)
  {
    if (tmp_devs_screen != null)
    {
    	tmp_devs_screen.remove(dvrScreen);
    }
    
    tmp_devs_screen.add(newScreen);
    //setOKButtonListener(newScreen);

    currentScreen = newScreen;

    validate();
    //this.repaint(200,0,500,600);
    this.repaint();
    //getContentPane().repaint();
  }
  
  /**
   * get the org.w3c.Node for a MutableTreeNode.
   */
  public Node getNode(Object treeNode)
  {
    return (Node) nodeMap.get(treeNode);
  }
  
  public AccreditConfigTree getConfigTree()
  {
    return tree;
  } 
 
  /**
   * Inserts a node and returns a reference to the new node.
   */
  private MutableTreeNode insertNode(String what, MutableTreeNode where)
  {
    return insertNode(what, where, UNKNOWN);
  }

  /**
   * Inserts a typed node and returns a reference to the new node.
   */
  private MutableTreeNode insertNode(String what, MutableTreeNode where, 
          int type)
  {

    //MutableTreeNode node = new DefaultMutableTreeNode(new UserObject(type, 
            //what));
    MutableTreeNode node = new DefaultMutableTreeNode(what);
    treeModel.insertNodeInto(node, where, where.getChildCount());
    //treeModel.insertNodeInto(subroot,root,0);
    return node;
	  //return null;

  }   // insertNode(Node,MutableTreeNode):MutableTreeNode


  /**
   * Inserts the document node.
   */
  private MutableTreeNode insertDocumentNode(Node what, 
          MutableTreeNode where)
  {
    MutableTreeNode treeNode = insertNode("<" + what.getNodeName() + '>', 
            where);

    nodeMap.put(treeNode, what);

    return treeNode;
  }

  /**
   * Inserts a document fragment.
   * Note that this only works for a fragment with a single
   * child. Returns the single child.
   */
  private DefaultMutableTreeNode insertFragmentNode(DocumentFragment what, 
          MutableTreeNode where)
  {

    Node parent = getNode(where);

    parent.appendChild(what);

    Node child = parent.getLastChild();
    DefaultMutableTreeNode treeNode = 
      (DefaultMutableTreeNode) (insertElementNode(child, where));

    return treeNode;
  }
  
  /**
   * Inserts an element node.
   * 插入一个节点
   */
  private MutableTreeNode insertElementNode(Node what, 
          MutableTreeNode where)
  {
    NodeFilter elementFilter = new NodeFilter()
    {

      /**
       * 
       */
      public short acceptNode(Node node)
      {
        String nodeName = node.getNodeName();
        System.out.println(".......................................................................");
        //System.out.println(nodeName.toString());
        //当节点为以下的值时,把它们过滤掉不显示

⌨️ 快捷键说明

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