📄 featurescreen.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/>. * *//** * Title: <p> * Description: <p> * Copyright: Copyright (c) <p> * Company: <p> * @author * @version 1.0 */package vocal.ui;import java.awt.*;import javax.swing.*;import vocal.data.FeatureData;import vocal.data.InvalidRequestException;import vocal.data.ConfigTree;import javax.swing.border.*;import java.awt.event.*;/** * $RCSfile$ * * @author $Author$, $Date$ * @version $Revision$ */public class FeatureScreen extends FormPanelScreen{ JPanel jPanel1 = new JPanel(); JScrollPane jScrollPane1 = new JScrollPane(); JPanel jPanel2 = new JPanel(); BorderLayout borderLayout2 = new BorderLayout(); BorderLayout borderLayout1 = new BorderLayout(); ConfigTree configTree1; FeatureData dataManager; ConfigureServers mainScreen; private boolean okFlag = false; JPanel jPanel4 = new JPanel(); BorderLayout borderLayout4 = new BorderLayout(); FlowLayout flowLayout2 = new FlowLayout(); Box box1; JPanel jPanel5 = new JPanel(); JLabel serverNameLabel = new JLabel(); JPanel jPanel6 = new JPanel(); protected Box box2; protected JPanel uaVMPanel = new JPanel(); protected JPanel jPanel7 = new JPanel(); protected FlowLayout flowLayout1 = new FlowLayout(); protected WholeNumberField portTextField = new WholeNumberField("Port"); protected JLabel groupDescriptionLabel = new JLabel(); protected JLabel hostNameLabel = new JLabel(); protected HostNameField hostNameTextField = new HostNameField("Host Name"); protected JLabel typeDescriptionLabel = new JLabel(); protected JLabel groupLabel = new JLabel(); protected LabelFieldPanel labelFieldPanel1 = new LabelFieldPanel(); protected JLabel portLabel = new JLabel(); protected JLabel typeLabel = new JLabel(); protected WholeNumberField lastPortTextField = new WholeNumberField("Last Port"); protected JLabel firstPortLabel = new JLabel(); protected WholeNumberField firstPortTextField = new WholeNumberField("First Port"); protected LabelFieldPanel labelFieldPanel2 = new LabelFieldPanel(); protected JLabel lastPortLabel = new JLabel(); protected JLabel vmTypeLabel = new JLabel(); protected JComboBox vmTypeComboBox = new JComboBox(new String[] { "vmail", "admin" }); protected FlowLayout flowLayout3 = new FlowLayout(); protected Border border1; protected TitledBorder titledBorder1; protected Border border2; private JLabel uaHostLabel = new JLabel(); private HostNameField uaHostTextField = new HostNameField("VM Host Name"); /** * * @param screen */ public FeatureScreen(ConfigureServers screen) { mainScreen = screen; try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } /** * * @throws Exception */ private void jbInit() throws Exception { box1 = Box.createVerticalBox(); box2 = Box.createVerticalBox(); border1 = BorderFactory.createLineBorder(Color.gray, 1); titledBorder1 = new TitledBorder(border1, "UA VM Servers"); border2 = BorderFactory.createCompoundBorder(titledBorder1, BorderFactory.createEmptyBorder(5, 20, 5, 20)); this.setLayout(borderLayout2); jPanel1.setLayout(borderLayout1); borderLayout2.setVgap(30); jPanel2.setLayout(borderLayout4); borderLayout1.setVgap(30); jPanel4.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0)); jPanel4.setMinimumSize(new Dimension(500, 100)); jPanel4.setPreferredSize(new Dimension(300, 50)); jPanel4.setLayout(flowLayout2); borderLayout4.setVgap(20); serverNameLabel.setForeground(Color.black); serverNameLabel.setHorizontalAlignment(SwingConstants.CENTER); serverNameLabel.setText("Feature Server "); jPanel2.setMinimumSize(new Dimension(134, 184)); jPanel2.setPreferredSize(new Dimension(310, 240)); jPanel7.setLayout(flowLayout1); portTextField.setToolTipText("port number of the Feature server"); groupDescriptionLabel.setForeground(Color.black); groupDescriptionLabel.setText("Unknown"); hostNameLabel.setForeground(Color.black); hostNameLabel.setText("Host Name:"); hostNameTextField.setToolTipText("IP address of this Feature server"); typeDescriptionLabel.setForeground(Color.black); typeDescriptionLabel.setText("Unknown"); groupLabel.setForeground(Color.black); groupLabel.setText("Group:"); labelFieldPanel1.setPreferredSize(new Dimension(300, 180)); labelFieldPanel1.setHorizontalGap(30); labelFieldPanel1.setVerticalGap(10); portLabel.setForeground(Color.black); portLabel.setText("Port:"); typeLabel.setForeground(Color.black); typeLabel.setText("Type:"); jPanel7.setPreferredSize(new Dimension(310, 80)); uaVMPanel.setPreferredSize(new Dimension(310, 80)); uaVMPanel.setLayout(flowLayout3); lastPortTextField.setToolTipText("last available port for receiving voice mail messages"); firstPortLabel.setText("First Port:"); firstPortLabel.setForeground(Color.black); firstPortTextField.setToolTipText("first available port for receiving voice mail messages"); labelFieldPanel2.setVerticalGap(0); labelFieldPanel2.setHorizontalGap(30); labelFieldPanel2.setBorder(border2); labelFieldPanel2.setPreferredSize(new Dimension(300, 180)); lastPortLabel.setForeground(Color.black); lastPortLabel.setText("Last Port:"); vmTypeLabel.setForeground(Color.black); vmTypeLabel.setText("Voicemail Server Type:"); vmTypeComboBox.setPreferredSize(new Dimension(100, 22)); flowLayout3.setVgap(10); uaHostLabel.setForeground(Color.black); uaHostLabel.setText("Host:"); uaHostTextField.addActionListener(new java.awt.event.ActionListener() { /** * * @param e */ public void actionPerformed(ActionEvent e) { uaHostTextField_actionPerformed(e); } }); uaHostTextField.setToolTipText("IP address of the User Agent Voice Mail server"); this.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.getViewport().add(jPanel2, null); jPanel2.add(jPanel4, BorderLayout.NORTH); jPanel4.add(box1, null); box1.add(jPanel5, null); jPanel5.add(serverNameLabel, null); box1.add(jPanel6, null); jPanel2.add(box2, BorderLayout.CENTER); configTree1 = mainScreen.getConfigTree(); box2.add(jPanel7, null); jPanel7.add(labelFieldPanel1, null); labelFieldPanel1.add(typeLabel, null); labelFieldPanel1.add(typeDescriptionLabel, null); labelFieldPanel1.add(groupLabel, null); labelFieldPanel1.add(groupDescriptionLabel, null); labelFieldPanel1.add(hostNameLabel, null); labelFieldPanel1.add(hostNameTextField, null); labelFieldPanel1.add(portLabel, null); labelFieldPanel1.add(portTextField, null); box2.add(uaVMPanel, null); uaVMPanel.add(labelFieldPanel2, null); labelFieldPanel2.add(uaHostLabel, null); labelFieldPanel2.add(uaHostTextField, null); labelFieldPanel2.add(firstPortLabel, null); labelFieldPanel2.add(firstPortTextField, null); labelFieldPanel2.add(lastPortLabel, null); labelFieldPanel2.add(lastPortTextField, null); labelFieldPanel2.add(vmTypeLabel, null); labelFieldPanel2.add(vmTypeComboBox, null); } // Set Functions /** * * @param str */ public void setHostField(String str) { hostNameTextField.setText(str); } /** * * @param str */ public void setPortField(String str) { portTextField.setText(str); } /** * * @param str */ public void setTypeLabel(String str) { typeDescriptionLabel.setText(str); } /** * * @param str */ public void setGroupLabel(String str) { groupDescriptionLabel.setText(str); } // Get Functions /** * */ public String getHostField() { return hostNameTextField.getText(); } /** * */ public String getPortField() { return portTextField.getText(); } /** * */ public String getTypeLabel() { return typeDescriptionLabel.getText(); } /** * */ public String getGroupLabel() { return groupDescriptionLabel.getText(); } /** * */ public boolean getOkFlag() { return okFlag; } /** */ public void displayData() { if (dataManager != null) { try { setHostField(dataManager.getHostData()); setPortField(dataManager.getPortData()); setTypeLabel(dataManager.getTypeData()); setGroupLabel(dataManager.getGroupData()); toValidate.clear(); toValidate.add(hostNameTextField); toValidate.add(portTextField); toValidate.add(hostNameTextField); if (!typeDescriptionLabel.getText().equals("Voicemail")) { System.out.println("removing uaVMPanel"); box2.remove(uaVMPanel); } else { System.out.println("adding uaVMPanel"); box2.add(uaVMPanel); uaHostTextField.setText(dataManager.getUaVMHostData()); firstPortTextField.setText(dataManager.getUaVMFirstPortData()); lastPortTextField.setText(dataManager.getUaVMLastPortData()); vmTypeComboBox.setSelectedItem(dataManager.getUaVMTypeData()); toValidate.add(uaHostTextField); toValidate.add(firstPortTextField); toValidate.add(lastPortTextField); } } catch (InvalidRequestException e) { e.printStackTrace(); } } } /** */ public void getData() throws InvalidRequestException { if (dataManager != null) { dataManager.setHostData(getHostField()); dataManager.setPortData(getPortField()); if (typeDescriptionLabel.getText().equals("Voicemail")) { System.out.println("setting first and last ports"); dataManager.setUaVMHostData(uaHostTextField.getText()); dataManager.setUaVMFirstPortData(firstPortTextField.getText()); dataManager.setUaVMLastPortData(lastPortTextField.getText()); dataManager.setUaVMTypeData((String) vmTypeComboBox.getSelectedItem()); } else { System.out.println("typeDescriptionLabel does not equal Voicemail: " + typeDescriptionLabel.getText()); } } } /** */ public void activate() { dataManager = configTree1.getFeatureData(); displayData(); // changing host and port changes the filename hostNameTextField.setEnabled(false); portTextField.setEnabled(false); } /** */ public void activateNew() { System.out.println("\n Inside FeatureScreen New Button "); dataManager = configTree1.getNewFeatureData(); hostNameTextField.setEnabled(true); portTextField.setEnabled(true); displayData(); } // Action Listener /** * * @param ev */ public void actionPerformed(ActionEvent ev) { System.out.println("\n ev.getSource = " + ev.getSource()); if (ev.getSource() == mainScreen.getOkButton()) { System.out.println("\n Ok Button Pressed"); if (!checkValidated()) { return; } try { getData(); } catch(InvalidRequestException e) { return; } if (dataManager != null) { try { dataManager.saveData(); } catch (InvalidRequestException e) { e.printStackTrace(); } } dataManager = configTree1.getFeatureData(); mainScreen.enableTree(); } } /** * */ public int confirmDelete() { return JOptionPane.showConfirmDialog(this, new String("If you delete or rename this Feature Server,\n" + "then you must regenerate all User Agents\n" + " with features in group " + groupDescriptionLabel.getText() + "\n" + " Continue?"), "Delete Feature Server", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); } /** * * @param e */ void uaHostTextField_actionPerformed(ActionEvent e) {}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -