📄 envscreen.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 java.awt.event.ActionEvent;
import vocal.data.EnvData;
//import vocal.data.PDPData;
import vocal.data.InvalidRequestException;
import vocal.data.ConfigTree;
/**
* $RCSfile: PolicyScreen.java,v $
*
* @author $Author: bsamson $, $Date: 2001/05/18 23:17:07 $
* @version $Revision: 1.16 $
*/
public class EnvScreen extends FormPanelScreen
{
JPanel jPanel1 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
JPanel jPanel2 = new JPanel();
LabelFieldPanel labelFieldPanel1 = new LabelFieldPanel();
JLabel hostNameLabel = new JLabel();
HostNameField hostNameTextField = new HostNameField("Host Name");
JLabel portLabel = new JLabel();
WholeNumberField portTextField = new WholeNumberField("Port");
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout1 = new BorderLayout();
ConfigTree configTree1;
EnvData dataManager;
ConfigureServers mainScreen;
JPanel jPanel3 = new JPanel();
FlowLayout flowLayout1 = new FlowLayout();
JPanel jPanel4 = new JPanel();
BorderLayout borderLayout4 = new BorderLayout();
FlowLayout flowLayout2 = new FlowLayout();
Box box1;
JPanel jPanel5 = new JPanel();
JLabel serverNameLabel = new JLabel();
JLabel smokeAlarmLabel = new JLabel();
WholeNumberField smokeAlarmField = new WholeNumberField("烟雾预警");
JLabel temperatureLabel = new JLabel();
WholeNumberField temperatureField =
new WholeNumberField("温度");
JLabel waterLabel = new JLabel();
WholeNumberField waterField = new WholeNumberField("湿度");
private JLabel groupDescriptionLabel = new JLabel();
private JLabel groupLabel = new JLabel();
private FlowLayout flowLayout3 = new FlowLayout();
/**
*
* @param screen
*/
public EnvScreen(ConfigureServers screen)
{
mainScreen = screen;
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
*
* @throws Exception
*/
private void jbInit() throws Exception
{
box1 = Box.createVerticalBox();
this.setLayout(borderLayout2);
jPanel1.setLayout(borderLayout1);
labelFieldPanel1.setPreferredSize(new Dimension(300, 200));
labelFieldPanel1.setHorizontalGap(30);
labelFieldPanel1.setVerticalGap(20);
hostNameLabel.setForeground(Color.black);
hostNameLabel.setText("Host Name:");
portLabel.setForeground(Color.black);
portLabel.setText("Port:");
jPanel2.setLayout(borderLayout4);
jPanel3.setLayout(flowLayout1);
jPanel4.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
jPanel4.setLayout(flowLayout2);
flowLayout1.setVgap(0);
hostNameTextField.setToolTipText("Env Client的IP地址");
portTextField.setToolTipText("Env Client的端口");
serverNameLabel.setForeground(Color.black);
serverNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
serverNameLabel.setText("Env Client ");
smokeAlarmLabel.setForeground(Color.black);
smokeAlarmLabel.setText("烟雾预警: ");
temperatureLabel.setForeground(Color.black);
temperatureLabel.setText(" 温度: ");
waterLabel.setForeground(Color.black);
waterLabel.setText(" 湿度: ");
groupDescriptionLabel.setForeground(Color.black);
groupDescriptionLabel.setText("Group:");
groupLabel.setForeground(Color.black);
groupLabel.setText("Unknown");
jPanel5.setLayout(flowLayout3);
flowLayout2.setVgap(20);
smokeAlarmField.setToolTipText("是否允许烟雾预警");
temperatureField.setToolTipText("是否允许有温度显示");
waterField.setToolTipText("是否允许有温度显示");
this.add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jPanel2, null);
jPanel2.add(jPanel3, BorderLayout.CENTER);
jPanel3.add(labelFieldPanel1, null);
labelFieldPanel1.add(groupDescriptionLabel, null);
labelFieldPanel1.add(groupLabel, null);
labelFieldPanel1.add(hostNameLabel, null);
labelFieldPanel1.add(hostNameTextField, null);
labelFieldPanel1.add(portLabel, null);
labelFieldPanel1.add(portTextField, null);
labelFieldPanel1.add(smokeAlarmLabel, null);
labelFieldPanel1.add(smokeAlarmField, null);
labelFieldPanel1.add(temperatureLabel, null);
labelFieldPanel1.add(temperatureField, null);
labelFieldPanel1.add(waterLabel, null);
labelFieldPanel1.add(waterField, null);
jPanel2.add(jPanel4, BorderLayout.NORTH);
jPanel4.add(box1, null);
box1.add(jPanel5, null);
jPanel5.add(serverNameLabel, null);
configTree1 = mainScreen.getConfigTree();
}
/**
*/
public void displayData()
{
if (dataManager != null)
{
try
{
groupLabel.setText(dataManager.getGroupData());
hostNameTextField.setText(dataManager.getHostData());
portTextField.setText(dataManager.getPortData());
temperatureField.setText(dataManager.getTemperatureData());
smokeAlarmField.setText(dataManager.getSmokeAlarmData());
waterField.setText(dataManager.getWaterData());
toValidate.clear();
toValidate.add(hostNameTextField);
toValidate.add(portTextField);
toValidate.add(smokeAlarmField);
toValidate.add(temperatureField);
toValidate.add(waterField);
}
catch (InvalidRequestException e)
{
e.printStackTrace();
}
}
}
/**
*/
public void getData()
throws InvalidRequestException
{
if (dataManager != null)
{
dataManager.setHostData(hostNameTextField.getText());
dataManager.setPortData(portTextField.getText());
dataManager.setTemperatureData(temperatureField.getText());
dataManager.setSmokeAlarmData(smokeAlarmField.getText());
dataManager.setWaterData(waterField.getText());
}
}
/**
*/
public void activate()
{
dataManager = configTree1.getEnvData();
displayData();
// changing host and port changes the filename
hostNameTextField.setEnabled(false);
portTextField.setEnabled(false);
}
/**
*/
public void activateNew()
{
dataManager = configTree1.getNewEnvData();
hostNameTextField.setEnabled(true);
portTextField.setEnabled(true);
displayData();
}
// Action Listener
/**
*
* @param ev
*/
public void actionPerformed(ActionEvent ev)
{
if (ev.getSource() == mainScreen.getOkButton())
{
if (!checkValidated())
{
return;
}
try
{
getData();
}
catch(InvalidRequestException e)
{
return;
}
if (dataManager != null)
{
try
{
System.out.println("saving data");
dataManager.saveData();
}
catch (InvalidRequestException e) {}
}
dataManager = configTree1.getEnvData();
mainScreen.enableTree();
}
}
public int confirmDelete()
{
return JOptionPane.showConfirmDialog(this,
new String("Are you sure you want to delete this Policy Server?"),
"Delete Policy Server Screen", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -