📄 redirectscreen.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.*;import java.awt.event.ActionEvent;/** * $RCSfile$ * * @author $Author$, $Date$ * @version $Revision$ */public class RedirectScreen extends FormPanelScreen{ // manually added ConfigureServers mainScreen; vocal.data.RedirectData dataManager; vocal.data.ConfigTree configTree; BorderLayout borderLayout1 = new BorderLayout(); private JScrollPane jScrollPane1 = new JScrollPane(); private JPanel jPanel3 = new JPanel(); private BorderLayout borderLayout2 = new BorderLayout(); private WholeNumberField syncPortTextField = new WholeNumberField("Sync Port"); private WholeNumberField portTextField = new WholeNumberField("Port"); private JLabel syncPortLabel = new JLabel(); private JLabel groupDescriptionLabel = new JLabel(); private FlowLayout flowLayout1 = new FlowLayout(); private JPanel jPanel2 = new JPanel(); private JPanel jPanel1 = new JPanel(); private JLabel groupLabel = new JLabel(); private LabelFieldPanel labelFieldPanel1 = new LabelFieldPanel(); private JLabel portLabel = new JLabel(); private JLabel jLabel1 = new JLabel(); private HostNameField hostNameTextField = new HostNameField("Host Name"); private JLabel hostLabel = new JLabel(); /** * * @param aMainScreen */ public RedirectScreen(ConfigureServers aMainScreen) { mainScreen = aMainScreen; configTree = mainScreen.getConfigTree(); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } /** * * @throws Exception */ private void jbInit() throws Exception { this.setLayout(borderLayout1); jPanel3.setLayout(borderLayout2); syncPortLabel.setText("Sync Port:"); syncPortLabel.setToolTipText(""); syncPortLabel.setForeground(Color.black); groupDescriptionLabel.setForeground(Color.black); groupDescriptionLabel.setText("Group:"); flowLayout1.setVgap(20); jPanel2.setPreferredSize(new Dimension(260, 150)); jPanel1.setLayout(flowLayout1); groupLabel.setForeground(Color.black); groupLabel.setText("Unknown"); labelFieldPanel1.setPreferredSize(new Dimension(250, 150)); labelFieldPanel1.setHorizontalGap(15); labelFieldPanel1.setVerticalGap(20); portLabel.setForeground(Color.black); portLabel.setToolTipText(""); portLabel.setText("Port:"); jLabel1.setForeground(Color.black); jLabel1.setText("Redirect Server"); hostLabel.setText("Host:"); hostLabel.setToolTipText(""); hostLabel.setForeground(Color.black); hostNameTextField.setToolTipText("IP address of the Redirect server"); portTextField.setToolTipText("port number used by the Redirect server"); syncPortTextField.setToolTipText("UDP port used to synchronize data between Redirect servers"); this.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.getViewport().add(jPanel3, null); jPanel3.add(jPanel2, BorderLayout.CENTER); jPanel2.add(labelFieldPanel1, null); labelFieldPanel1.add(groupDescriptionLabel, null); labelFieldPanel1.add(groupLabel, null); labelFieldPanel1.add(hostLabel, null); labelFieldPanel1.add(hostNameTextField, null); labelFieldPanel1.add(portLabel, null); labelFieldPanel1.add(portTextField, null); labelFieldPanel1.add(syncPortLabel, null); labelFieldPanel1.add(syncPortTextField, null); jPanel3.add(jPanel1, BorderLayout.NORTH); jPanel1.add(jLabel1, null); } /** */ public void displayData() { if (dataManager != null) { try { groupLabel.setText(dataManager.getGroupData()); hostNameTextField.setText(dataManager.getHostData()); portTextField.setText(dataManager.getPortData()); syncPortTextField.setText(dataManager.getSyncPortData()); toValidate.clear(); toValidate.add(hostNameTextField); toValidate.add(portTextField); toValidate.add(syncPortTextField); } catch (InvalidRequestException e) { e.printStackTrace(); } } } /** */ private void getData() throws InvalidRequestException { if (dataManager != null) { dataManager.setHostData(hostNameTextField.getText()); dataManager.setPortData(portTextField.getText()); dataManager.setSyncPortData(syncPortTextField.getText()); } } /** */ public void activate() { dataManager = configTree.getRedirectData(); displayData(); // changing host and port changes the filename hostNameTextField.setEnabled(false); portTextField.setEnabled(false); } /** */ public void activateNew() { dataManager = configTree.getNewRedirectData(); hostNameTextField.setEnabled(true); portTextField.setEnabled(true); displayData(); } /** * called when the Ok button is pressed */ public void actionPerformed(ActionEvent e) { if (dataManager != null) { if (!checkValidated()) { return; } try { getData(); } catch(InvalidRequestException e1) { return; } try { dataManager.saveData(); } catch (InvalidRequestException e2) { e2.printStackTrace(); } } dataManager = configTree.getRedirectData(); mainScreen.enableTree(); } public int confirmDelete() { return JOptionPane.showConfirmDialog(this, new String("Are you sure you want to delete this Redirect Server?"), "Delete Redirect Server Screen", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -