192 lines
5.4 KiB
Java
192 lines
5.4 KiB
Java
package jnet.client.gui.dialog.object;
|
|
|
|
import javax.swing.DefaultComboBoxModel;
|
|
import javax.swing.JCheckBox;
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
import jnet.lib.object.MapObject;
|
|
|
|
class TabServices extends JPanel {
|
|
|
|
private MapObject obj;
|
|
private boolean newObject;
|
|
|
|
private JCheckBox winboxBox = new JCheckBox("Winbox");
|
|
private JTextField portWinbox = new JTextField("8291");
|
|
private JCheckBox sshBox = new JCheckBox("SSH");
|
|
private JTextField portSsh = new JTextField("22");
|
|
private JCheckBox wwwBox = new JCheckBox("Web");
|
|
private JTextField portWww = new JTextField("80");
|
|
private JComboBox<String> wwwVerzeComboBox = new JComboBox<String>();
|
|
private JCheckBox telnetBox = new JCheckBox("Telnet");
|
|
private JTextField portTelnet = new JTextField("21");
|
|
private JCheckBox smstBox = new JCheckBox("Summit SMS");
|
|
private JTextField portSms = new JTextField("5020");
|
|
private JComboBox<String> smsVerzeComboBox = new JComboBox<String>();
|
|
|
|
public TabServices(MapObject obj, boolean newObject) {
|
|
this.obj = obj;
|
|
this.newObject = newObject;
|
|
|
|
this.setLayout(null);
|
|
|
|
winboxBox.setBounds(20, 30, 80, 25);
|
|
this.add(winboxBox);
|
|
|
|
JLabel winbox_port = new JLabel("port:");
|
|
winbox_port.setBounds(130, 30, 60, 25);
|
|
this.add(winbox_port);
|
|
|
|
portWinbox.setBounds(180, 30, 60, 25);
|
|
this.add(portWinbox);
|
|
|
|
sshBox.setBounds(20, 60, 80, 25);
|
|
this.add(sshBox);
|
|
|
|
JLabel ssh_port = new JLabel("port:");
|
|
ssh_port.setBounds(130, 60, 60, 25);
|
|
this.add(ssh_port);
|
|
|
|
portSsh.setBounds(180, 60, 60, 25);
|
|
this.add(portSsh);
|
|
|
|
wwwBox.setBounds(20, 90, 80, 25);
|
|
this.add(wwwBox);
|
|
|
|
JLabel www_port = new JLabel("port:");
|
|
www_port.setBounds(130, 90, 60, 25);
|
|
this.add(www_port);
|
|
|
|
portWww.setBounds(180, 90, 60, 25);
|
|
this.add(portWww);
|
|
|
|
JLabel www_verze = new JLabel("verze:");
|
|
www_verze.setBounds(260, 90, 60, 25);
|
|
this.add(www_verze);
|
|
|
|
wwwVerzeComboBox.setModel(new DefaultComboBoxModel(new String[]{"HTTP", "HTTPS"}));
|
|
wwwVerzeComboBox.setBounds(320, 90, 80, 25);
|
|
this.add(wwwVerzeComboBox);
|
|
|
|
telnetBox.setBounds(20, 120, 80, 25);
|
|
this.add(telnetBox);
|
|
|
|
JLabel telnet_port = new JLabel("port:");
|
|
telnet_port.setBounds(130, 120, 60, 25);
|
|
this.add(telnet_port);
|
|
|
|
portTelnet.setBounds(180, 120, 60, 25);
|
|
this.add(portTelnet);
|
|
|
|
smstBox.setBounds(20, 150, 80, 25);
|
|
this.add(smstBox);
|
|
|
|
JLabel sms_port = new JLabel("port:");
|
|
sms_port.setBounds(130, 150, 60, 25);
|
|
this.add(sms_port);
|
|
|
|
portSms.setBounds(180, 150, 60, 25);
|
|
this.add(portSms);
|
|
|
|
JLabel sms_verze = new JLabel("verze:");
|
|
sms_verze.setBounds(260, 150, 60, 25);
|
|
this.add(sms_verze);
|
|
|
|
smsVerzeComboBox.setModel(new DefaultComboBoxModel(new String[]{"SDV", "BT"}));
|
|
smsVerzeComboBox.setBounds(320, 150, 80, 25);
|
|
this.add(smsVerzeComboBox);
|
|
|
|
// predvyplneni poli
|
|
if (!newObject) {
|
|
winboxBox.setSelected(obj.isWinbox());
|
|
portWinbox.setText(obj.getWinboxPort());
|
|
sshBox.setSelected(obj.isSsh());
|
|
portSsh.setText(obj.getSshPort());
|
|
wwwBox.setSelected(obj.isWeb());
|
|
portWww.setText(obj.getWebPort());
|
|
wwwVerzeComboBox.setSelectedIndex(obj.getWebVerze());
|
|
telnetBox.setSelected(obj.isTelnet());
|
|
portTelnet.setText(obj.getTelnetPort());
|
|
smstBox.setSelected(obj.isSms());
|
|
portSms.setText(obj.getSmsPort());
|
|
smsVerzeComboBox.setSelectedIndex(obj.getSmsVerze());
|
|
}
|
|
}
|
|
|
|
public boolean isWinbox() {
|
|
return winboxBox.isSelected();
|
|
}
|
|
|
|
public String getWinboxPort() {
|
|
if (validatePort(portWinbox.getText())) {
|
|
return portWinbox.getText();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public boolean isSsh() {
|
|
return sshBox.isSelected();
|
|
}
|
|
|
|
public String getSshPort() {
|
|
if (validatePort(portSsh.getText())) {
|
|
return portSsh.getText();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public boolean isWeb() {
|
|
return wwwBox.isSelected();
|
|
}
|
|
|
|
public String getWebPort() {
|
|
if (validatePort(portWww.getText())) {
|
|
return portWww.getText();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int getWebVersion() {
|
|
return wwwVerzeComboBox.getSelectedIndex();
|
|
}
|
|
|
|
public boolean isTelnet() {
|
|
return telnetBox.isSelected();
|
|
}
|
|
|
|
public String getTelnetPort() {
|
|
if (validatePort(portTelnet.getText())) {
|
|
return portTelnet.getText();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public boolean isSms() {
|
|
return smstBox.isSelected();
|
|
}
|
|
|
|
public String getSmsPort() {
|
|
if (validatePort(portSms.getText())) {
|
|
return portSms.getText();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int getSmsVersion() {
|
|
return smsVerzeComboBox.getSelectedIndex();
|
|
}
|
|
|
|
private boolean validatePort(String port) {
|
|
try {
|
|
int pNum = Integer.parseInt(port);
|
|
if ((pNum > 0) && (pNum < 65536)) {
|
|
return true;
|
|
}
|
|
} catch (NumberFormatException e) {
|
|
}
|
|
return false;
|
|
}
|
|
}
|