📄 heartbeatscreen.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: HeartbeatScreen.java,v $ * * @author $Author: bsamson $, $Date: 2001/05/18 23:17:07 $ * @version $Revision: 1.12 $ */public class HeartbeatScreen extends FormPanelScreen{ // manually added ConfigureServers mainScreen; vocal.data.HeartbeatData dataManager; vocal.data.ConfigTree configTree; BorderLayout borderLayout1 = new BorderLayout(); private JPanel jPanel4 = new JPanel(); private JScrollPane jScrollPane1 = new JScrollPane(); private JLabel groupDescriptionLabel = new JLabel(); private FlowLayout flowLayout1 = new FlowLayout(); private JPanel jPanel3 = new JPanel(); private JPanel jPanel2 = new JPanel(); private JPanel jPanel1 = new JPanel(); private JLabel groupLabel = new JLabel(); private LabelFieldPanel labelFieldPanel1 = new LabelFieldPanel(); private BorderLayout borderLayout2 = new BorderLayout(); private JLabel jLabel1 = new JLabel(); private HostNameField hostNameTextField = new HostNameField("Host name"); private JLabel hostLabel = new JLabel(); private BorderLayout borderLayout3 = new BorderLayout(); /** * * @param aMainScreen */ public HeartbeatScreen(ConfigureServers aMainScreen) { mainScreen = aMainScreen; configTree = mainScreen.getConfigTree(); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } /** * * @throws Exception */ private void jbInit() throws Exception { this.setLayout(borderLayout1); groupDescriptionLabel.setForeground(Color.black); groupDescriptionLabel.setText("Group:"); flowLayout1.setVgap(20); jPanel3.setLayout(borderLayout2); jPanel1.setLayout(flowLayout1); groupLabel.setForeground(Color.black); groupLabel.setText("Unknown"); labelFieldPanel1.setPreferredSize(new Dimension(250, 100)); labelFieldPanel1.setHorizontalGap(15); labelFieldPanel1.setVerticalGap(20); jLabel1.setForeground(Color.black); jLabel1.setText("Heartbeat Server"); hostLabel.setText("Host:"); hostLabel.setToolTipText(""); hostLabel.setForeground(Color.black); jPanel4.setLayout(borderLayout3); hostNameTextField.setToolTipText("IP address of this Heartbeat server"); this.add(jPanel4, BorderLayout.CENTER); jPanel4.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); jPanel3.add(jPanel1, BorderLayout.NORTH); jPanel1.add(jLabel1, null); } /** */ public void displayData() { if (dataManager != null) { try { groupLabel.setText(dataManager.getGroupData()); hostNameTextField.setText(dataManager.getHostData()); toValidate.clear(); toValidate.add(hostNameTextField); } catch (InvalidRequestException e) { e.printStackTrace(); } } } /** */ private void getData() throws InvalidRequestException { if (dataManager != null) { dataManager.setHostData(hostNameTextField.getText()); } } /** */ public void activate() { dataManager = configTree.getHeartbeatData(); displayData(); // changing host and port changes the filename hostNameTextField.setEnabled(false); } /** */ public void activateNew() { dataManager = configTree.getNewHeartbeatData(); hostNameTextField.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.getHeartbeatData(); mainScreen.enableTree(); } public int confirmDelete() { return JOptionPane.showConfirmDialog(this, new String("Are you sure you want to delete this Heartbeat Server?"), "Delete Heartbeat Server Screen", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -