📄 configureservers.java
字号:
/* * ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY 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. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */package vocal.ui;import vocal.data.*;import vocal.data.TreeNodeTypes;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;import javax.swing.event.TreeSelectionEvent;import javax.swing.event.TreeSelectionListener;import javax.swing.border.*;/** * This class manages the screens and the buttons that make * the screens appear and disappear as the user navigates through * the ConfigTree. * @author $Author: bsamson $, $Date: 2002/04/15 17:56:24 $ * @version $Revision: 1.23 $ */public class ConfigureServers extends JDialog implements TreeNodeTypes{ private int currentNodeType = UNKNOWN; private FormPanelScreen currentScreen = null; // used for JOptionPane display private Container parent; BlankScreen blankScreen; GroupScreen groupScreen; CdrScreen cdrScreen; HeartbeatScreen heartbeatScreen; PolicyScreen pdpScreen; FeatureScreen featureScreen; MarshalScreen marshalScreen; RedirectScreen redirectScreen; OSPServerScreen ospScreen; SystemData systemData; DialPlanScreen ipDialPlanScreen; DialPlanScreen digitalDialPlanScreen; JPanel jPanel1 = new JPanel(); JPanel topPanel = new JPanel(); JPanel jPanel3 = new JPanel(); JButton backButton = new JButton(); JSplitPane jSplitPane1 = new JSplitPane(); JPanel buttonPanel = new JPanel(); FlowLayout flowLayout1 = new FlowLayout(); BorderLayout borderLayout1 = new BorderLayout(); FlowLayout flowLayout3 = new FlowLayout(); JButton okButton = new JButton(); JButton newButton = new JButton(); JButton deleteButton = new JButton(); JPanel buttonGridPanel = new JPanel(); GridLayout gridLayout1 = new GridLayout(); JButton cancelButton = new JButton(); JPanel treePanel = new JPanel(); JPanel formPanel = new JPanel(); JPanel tempPanel = new JPanel(); JScrollPane jScrollPane2 = new JScrollPane(); ConfigTree configTree1 = new ConfigTree(); BorderLayout borderLayout2 = new BorderLayout(); BorderLayout borderLayout3 = new BorderLayout(); /** * * @param aParent */ public ConfigureServers(Container aParent) { parent = aParent; setTitle("Configure Servers"); init(); try { jbInit(); pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2); } catch (Exception e) { e.printStackTrace(); } } // public methods /** * */ public ConfigTree getConfigTree() { return configTree1; } /** * */ public void enableTree() { configTree1.setEnabled(true); } public void disableTree() { configTree1.setEnabled(false); } /** * */ public JButton getNewButton() { return newButton; } /** * */ public JButton getOkButton() { return okButton; } /** * */ public JButton getCancelButton() { return cancelButton; } /** * */ public JButton getDeleteButton() { return deleteButton; } // get screen methods /** * */ public FormPanelScreen getCdrScreen() { return cdrScreen; } /** * */ public FormPanelScreen getHeartbeatScreen() { return heartbeatScreen; } /** * */ public FormPanelScreen getFeatureScreen() { return featureScreen; } /** * */ public FormPanelScreen getMarshalScreen() { return marshalScreen; } /** * */ public FormPanelScreen getPdpScreen() { return pdpScreen; } /** * */ public FormPanelScreen getRedirectScreen() { return redirectScreen; } /** */ private void init() { blankScreen = new BlankScreen(); groupScreen = new GroupScreen(this); cdrScreen = new CdrScreen(this); heartbeatScreen = new HeartbeatScreen(this); pdpScreen = new PolicyScreen(this); featureScreen = new FeatureScreen(this); marshalScreen = new MarshalScreen(this); redirectScreen = new RedirectScreen(this); ospScreen = new OSPServerScreen(this); systemData = new SystemData(this); ipDialPlanScreen = new DialPlanScreen(this, "IP"); digitalDialPlanScreen = new DialPlanScreen(this, "Digital"); initializeButtons(); setTreeListener(); } /** * * @throws Exception */ private void jbInit() throws Exception { jPanel1.setLayout(borderLayout1); topPanel.setLayout(flowLayout3); jPanel3.setLayout(borderLayout2); backButton.setToolTipText("Return to Login screen to configure users"); backButton.setText("Back"); buttonPanel.setLayout(flowLayout1); flowLayout1.setHgap(0); flowLayout1.setVgap(0); okButton.setText("OK"); newButton.setText("New"); deleteButton.setText("Delete"); buttonGridPanel.setLayout(gridLayout1); gridLayout1.setColumns(4); gridLayout1.setVgap(5); cancelButton.setText("Cancel"); this.setModal(true); jSplitPane1.setTopComponent(null); buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); flowLayout3.setAlignment(FlowLayout.LEFT); formPanel.setPreferredSize(new Dimension(150, 200)); formPanel.setLayout(borderLayout3); jPanel1.setPreferredSize(new Dimension(660, 440)); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.add(topPanel, BorderLayout.NORTH); topPanel.add(backButton, null); jPanel1.add(jPanel3, BorderLayout.CENTER); jPanel3.add(jSplitPane1, BorderLayout.CENTER); jSplitPane1.add(formPanel, JSplitPane.RIGHT); formPanel.add(tempPanel, BorderLayout.NORTH); jSplitPane1.add(jScrollPane2, JSplitPane.LEFT); this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); buttonPanel.add(buttonGridPanel, null); buttonGridPanel.add(newButton, null); buttonGridPanel.add(okButton, null); buttonGridPanel.add(cancelButton, null); buttonGridPanel.add(deleteButton, null); jScrollPane2.getViewport().add(configTree1, BorderLayout.CENTER); jSplitPane1.setDividerLocation(275); } /** * * @param newScreen */ private void setCurrentScreen(FormPanelScreen newScreen) { if (currentScreen == null) { formPanel.remove(tempPanel); } else { formPanel.remove(currentScreen); } formPanel.add(newScreen); setOKButtonListener(newScreen); currentScreen = newScreen; validate(); getContentPane().repaint(); } /** */ private void setTreeListener() { configTree1.addTreeSelectionListener(new TreeSelectionListener() { /** * * @param e */ public void valueChanged(TreeSelectionEvent e) { int type = configTree1.getSelectedNodeType(); System.out.println("selected node is " + TreeNodeTypes.strings[type] + " (" + Integer.toString(type) + ")"); currentNodeType = configTree1.getSelectedNodeType(); /* * We do two switch statements here so that we can * first set the buttons for sets of similar screens * and then deal with each screen individually. */ switch (currentNodeType) { case UNKNOWN: case SYSTEM: case SERVERS: { newButton.setEnabled(false); okButton.setEnabled(false); cancelButton.setEnabled(false); deleteButton.setEnabled(false); break; } case GLOBAL: case DIGITAL_DIAL_PLAN: case IP_DIAL_PLAN: case OSP_SERVER: { // set buttons newButton.setEnabled(false); okButton.setEnabled(true); cancelButton.setEnabled(true); deleteButton.setEnabled(false); break; } // feature and marshal servers cannot make new types case FEATURE_SERVERS: case MARSHAL_SERVERS: { newButton.setEnabled(false); okButton.setEnabled(false); cancelButton.setEnabled(false); deleteButton.setEnabled(false); break; } // feature and marshal types can make new groups case FEATURE_TYPE: case MARSHAL_TYPE: // these four top-level servers can make new groups case CDR_SERVERS: case HEARTBEAT_SERVERS: case JTAPI_SERVERS: case PDP_SERVERS: case REDIRECT_SERVERS: { // set buttons newButton.setEnabled(true); okButton.setEnabled(true); cancelButton.setEnabled(true); deleteButton.setEnabled(false); break; } // groups can make new individual servers case CDR_GROUP: case HEARTBEAT_GROUP: case FEATURE_GROUP:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -