cteni SNMPT informaci o objektu a jejich rozhranich
parent
c28c2dfe19
commit
4b7d0e3e8f
|
|
@ -71,9 +71,6 @@ public class Client {
|
||||||
LogFile.printDebug("Debug mode on");
|
LogFile.printDebug("Debug mode on");
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// okno
|
|
||||||
///
|
|
||||||
///
|
///
|
||||||
/// tray icon
|
/// tray icon
|
||||||
///
|
///
|
||||||
|
|
@ -93,6 +90,8 @@ public class Client {
|
||||||
clientThread = new Thread(client);
|
clientThread = new Thread(client);
|
||||||
clientThread.start();
|
clientThread.start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package jnet.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import jnet.client.gui.UIUpdater;
|
import jnet.client.gui.UIUpdater;
|
||||||
|
|
@ -16,6 +17,8 @@ import jnet.lib.object.OnlineClients;
|
||||||
import jnet.lib.object.ServerConfig;
|
import jnet.lib.object.ServerConfig;
|
||||||
import jnet.lib.object.SnmpProfile;
|
import jnet.lib.object.SnmpProfile;
|
||||||
import jnet.lib.object.User;
|
import jnet.lib.object.User;
|
||||||
|
import jnet.lib.snmp.DeviceInfo;
|
||||||
|
import jnet.lib.snmp.Interface;
|
||||||
|
|
||||||
public class ClientMessageParser {
|
public class ClientMessageParser {
|
||||||
|
|
||||||
|
|
@ -45,6 +48,8 @@ public class ClientMessageParser {
|
||||||
handlers.put(Message.USER_EDIT, ClientMessageParser::handleUserEdit);
|
handlers.put(Message.USER_EDIT, ClientMessageParser::handleUserEdit);
|
||||||
handlers.put(Message.DELETE_LOG, ClientMessageParser::handleDeleteLog);
|
handlers.put(Message.DELETE_LOG, ClientMessageParser::handleDeleteLog);
|
||||||
handlers.put(Message.SERVER_CONFIG, ClientMessageParser::handleServerConfig);
|
handlers.put(Message.SERVER_CONFIG, ClientMessageParser::handleServerConfig);
|
||||||
|
handlers.put(Message.SNMP_OBJECT_INFO, ClientMessageParser::handleSnmpObjectInfo);
|
||||||
|
handlers.put(Message.SNMP_OBJECT_INTERFACE, ClientMessageParser:: handleSnmpObjectInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parse(Message msg) {
|
public static void parse(Message msg) {
|
||||||
|
|
@ -210,4 +215,17 @@ public class ClientMessageParser {
|
||||||
Client.serverConfig = (ServerConfig) msg.getMsg();
|
Client.serverConfig = (ServerConfig) msg.getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleSnmpObjectInfo(Message msg) {
|
||||||
|
Object[] msg_obj = (Object[]) msg.getMsg();
|
||||||
|
String frame = (String) msg_obj[0];
|
||||||
|
DeviceInfo di = (DeviceInfo) msg_obj[1];
|
||||||
|
UIUpdater.updateObjectInfo(frame, di);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleSnmpObjectInterface(Message msg) {
|
||||||
|
Object[] msg_obj = (Object[]) msg.getMsg();
|
||||||
|
String frame = (String) msg_obj[0];
|
||||||
|
List<Interface> iface = (List<Interface>) msg_obj[1];
|
||||||
|
UIUpdater.updateObjectInterface(frame, iface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
package jnet.client.gui;
|
package jnet.client.gui;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.*;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.util.List;
|
||||||
|
import jnet.client.gui.dialog.object.ObjectDialog;
|
||||||
|
import jnet.lib.snmp.DeviceInfo;
|
||||||
|
import jnet.lib.snmp.Interface;
|
||||||
|
|
||||||
public class UIUpdater {
|
public class UIUpdater {
|
||||||
|
|
||||||
|
|
@ -30,4 +34,26 @@ public class UIUpdater {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateObjectInfo(String frameName, DeviceInfo di) {
|
||||||
|
for (Window w : JFrame.getWindows()) {
|
||||||
|
if (w instanceof JFrame && frameName.equals(w.getName())) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
((ObjectDialog) w).setDeviceInfo(di);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateObjectInterface(String frameName, List<Interface> iface) {
|
||||||
|
for (Window w : JFrame.getWindows()) {
|
||||||
|
if (w instanceof JFrame && frameName.equals(w.getName())) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
((ObjectDialog) w).setDeviceInterface(iface);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,16 @@ public class Window extends JFrame {
|
||||||
public Window() {
|
public Window() {
|
||||||
super(Client.APP_NAME); //titulek okna
|
super(Client.APP_NAME); //titulek okna
|
||||||
|
|
||||||
|
//identifikator okna
|
||||||
|
this.setName("mainWindow");
|
||||||
|
|
||||||
Dimension d = new Dimension(1024, 800);
|
Dimension d = new Dimension(1024, 800);
|
||||||
this.setPreferredSize(d);
|
this.setPreferredSize(d);
|
||||||
this.setSize(d);
|
this.setSize(d);
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.setIconImage(ImageIO.read(new File("img/app.png")));
|
this.setIconImage(ImageIO.read(getClass().getResourceAsStream("/img/app.png")));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LogFile.printErr("APP icon exception");
|
LogFile.printErr("APP icon exception");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ package jnet.client.gui.dialog.object;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.regex.Matcher;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
@ -14,7 +13,8 @@ import jnet.client.network.NettyClient;
|
||||||
import jnet.lib.Message;
|
import jnet.lib.Message;
|
||||||
import jnet.lib.Status;
|
import jnet.lib.Status;
|
||||||
import jnet.lib.object.MapObject;
|
import jnet.lib.object.MapObject;
|
||||||
|
import jnet.lib.snmp.DeviceInfo;
|
||||||
|
import jnet.lib.snmp.Interface;
|
||||||
|
|
||||||
public class ObjectDialog extends JFrame {
|
public class ObjectDialog extends JFrame {
|
||||||
|
|
||||||
|
|
@ -22,10 +22,18 @@ public class ObjectDialog extends JFrame {
|
||||||
private int mapId;
|
private int mapId;
|
||||||
private Boolean newObject;
|
private Boolean newObject;
|
||||||
|
|
||||||
|
private TabInfo tabInfo;
|
||||||
|
private TabSettings tabSettings;
|
||||||
|
private TabServices tabServices;
|
||||||
|
private TabEvents tabEvents;
|
||||||
|
|
||||||
public ObjectDialog(MapObject obj) {
|
public ObjectDialog(MapObject obj) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.mapId = obj.getMap();
|
this.mapId = obj.getMap();
|
||||||
this.newObject = false;
|
this.newObject = false;
|
||||||
|
|
||||||
|
// identifikator okna
|
||||||
|
this.setName("object_detail_" + obj.getId());
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,6 +45,7 @@ public class ObjectDialog extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
if (newObject) {
|
if (newObject) {
|
||||||
setTitle("Nový objekt");
|
setTitle("Nový objekt");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -55,11 +64,10 @@ public class ObjectDialog extends JFrame {
|
||||||
|
|
||||||
// JScrollPane tabNastaveni = new JScrollPane(tabNastaveni(),
|
// JScrollPane tabNastaveni = new JScrollPane(tabNastaveni(),
|
||||||
// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
|
tabInfo = new TabInfo(this.getName(), obj);
|
||||||
TabInfo tabInfo = new TabInfo();
|
tabSettings = new TabSettings(obj, newObject);
|
||||||
TabSettings tabSettings = new TabSettings(obj, newObject);
|
tabServices = new TabServices(obj, newObject);
|
||||||
TabServices tabServices = new TabServices(obj, newObject);
|
tabEvents = new TabEvents(obj);
|
||||||
TabEvents tabEvents = new TabEvents(obj);
|
|
||||||
|
|
||||||
tabbedPane.addTab("Informace", tabInfo);
|
tabbedPane.addTab("Informace", tabInfo);
|
||||||
tabbedPane.addTab("Nastaveni", tabSettings);
|
tabbedPane.addTab("Nastaveni", tabSettings);
|
||||||
|
|
@ -100,18 +108,38 @@ public class ObjectDialog extends JFrame {
|
||||||
obj.setActive(tabSettings.isActive());
|
obj.setActive(tabSettings.isActive());
|
||||||
obj.setDescription(tabSettings.getDesc());
|
obj.setDescription(tabSettings.getDesc());
|
||||||
obj.setLocation(tabSettings.getLoc());
|
obj.setLocation(tabSettings.getLoc());
|
||||||
// TODO validaci portu
|
|
||||||
obj.setWinbox(tabServices.isWinbox());
|
obj.setWinbox(tabServices.isWinbox());
|
||||||
obj.setWinboxPort(tabServices.getWinboxPort());
|
String winboxPort = tabServices.getWinboxPort();
|
||||||
|
if (winboxPort == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj.setWinboxPort(winboxPort);
|
||||||
obj.setSsh(tabServices.isSsh());
|
obj.setSsh(tabServices.isSsh());
|
||||||
obj.setSshPort(tabServices.getSshPort());
|
String sshPort = tabServices.getSshPort();
|
||||||
|
if (sshPort == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj.setSshPort(sshPort);
|
||||||
obj.setWeb(tabServices.isWeb());
|
obj.setWeb(tabServices.isWeb());
|
||||||
obj.setWebPort(tabServices.getWebPort());
|
String webPort = tabServices.getWebPort();
|
||||||
|
if (webPort == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj.setWebPort(webPort);
|
||||||
obj.setWebVerze(tabServices.getWebVersion());
|
obj.setWebVerze(tabServices.getWebVersion());
|
||||||
obj.setTelnet(tabServices.isTelnet());
|
obj.setTelnet(tabServices.isTelnet());
|
||||||
obj.setTelnetPort(tabServices.getTelnetPort());
|
String telnetPort = tabServices.getTelnetPort();
|
||||||
|
if (telnetPort == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj.setTelnetPort(telnetPort);
|
||||||
obj.setSms(tabServices.isSms());
|
obj.setSms(tabServices.isSms());
|
||||||
obj.setSmsPort(tabServices.getSmsPort());
|
String smsPort = tabServices.getSmsPort();
|
||||||
|
if (smsPort == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj.setSmsPort(smsPort);
|
||||||
obj.setSmsVerze(tabServices.getSmsVersion());
|
obj.setSmsVerze(tabServices.getSmsVersion());
|
||||||
|
|
||||||
if (!obj.isActive() || newObject) {
|
if (!obj.isActive() || newObject) {
|
||||||
|
|
@ -144,25 +172,8 @@ public class ObjectDialog extends JFrame {
|
||||||
pane.add(cancel);
|
pane.add(cancel);
|
||||||
|
|
||||||
add(pane, BorderLayout.PAGE_END);
|
add(pane, BorderLayout.PAGE_END);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean validatePort(String port) {
|
|
||||||
try {
|
|
||||||
int pNum = Integer.parseInt(port);
|
|
||||||
if ((pNum > 0) && (pNum < 65536)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getStatus(int status) {
|
private String getStatus(int status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Status.OK: // online
|
case Status.OK: // online
|
||||||
|
|
@ -176,7 +187,15 @@ public class ObjectDialog extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDeviceInfo(DeviceInfo di){
|
||||||
|
this.tabInfo.setName(di.getSysName());
|
||||||
|
this.tabInfo.setDesc(di.getSysDescr());
|
||||||
|
this.tabInfo.setUptime(di.getSysUptime());
|
||||||
|
this.tabInfo.setVendor(di.getSysObjectID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceInterface(List<Interface> iface){
|
||||||
|
this.tabInfo.setInterface(iface);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,132 @@
|
||||||
package jnet.client.gui.dialog.object;
|
package jnet.client.gui.dialog.object;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import jnet.client.network.NettyClient;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.MapObject;
|
||||||
|
import jnet.lib.snmp.Interface;
|
||||||
|
|
||||||
public class TabInfo extends JPanel {
|
public class TabInfo extends JPanel {
|
||||||
|
|
||||||
public TabInfo() {
|
private String frameName;
|
||||||
|
private MapObject obj;
|
||||||
|
private JLabel uptime = new JLabel();
|
||||||
|
private JLabel name = new JLabel();
|
||||||
|
private JLabel description = new JLabel();
|
||||||
|
private JLabel vendor = new JLabel();
|
||||||
|
private DefaultTableModel tableModel;
|
||||||
|
private JTable ifaceTable;
|
||||||
|
|
||||||
|
public TabInfo(String frameName, MapObject obj) {
|
||||||
|
this.obj = obj;
|
||||||
|
this.frameName = frameName;
|
||||||
|
init();
|
||||||
|
|
||||||
|
// odeslani SNMP dotazu na server
|
||||||
|
snmpRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
|
||||||
|
this.setLayout(null);
|
||||||
|
this.setBounds(0, 0, 600, 520);
|
||||||
|
|
||||||
|
int x1 = 20;
|
||||||
|
int x2 = 100;
|
||||||
|
int y = 30;
|
||||||
|
|
||||||
|
JLabel labelName = new JLabel("Název:");
|
||||||
|
labelName.setBounds(x1, y, 90, 30);
|
||||||
|
this.add(labelName);
|
||||||
|
name.setBounds(x2, y, 300, 30);
|
||||||
|
this.add(name);
|
||||||
|
y = y + 30;
|
||||||
|
|
||||||
|
JLabel labelDesc = new JLabel("Popis:");
|
||||||
|
labelDesc.setBounds(x1, y, 90, 30);
|
||||||
|
this.add(labelDesc);
|
||||||
|
description.setBounds(x2, y, 300, 30);
|
||||||
|
this.add(description);
|
||||||
|
y = y + 30;
|
||||||
|
|
||||||
|
JLabel labelVendor = new JLabel("Výrobce:");
|
||||||
|
labelVendor.setBounds(x1, y, 90, 30);
|
||||||
|
this.add(labelVendor);
|
||||||
|
vendor.setBounds(x2, y, 300, 30);
|
||||||
|
this.add(vendor);
|
||||||
|
y = y + 30;
|
||||||
|
|
||||||
|
JLabel labelUptime = new JLabel("Uptime:");
|
||||||
|
labelUptime.setBounds(x1, y, 90, 30);
|
||||||
|
this.add(labelUptime);
|
||||||
|
uptime.setBounds(x2, y, 300, 30);
|
||||||
|
this.add(uptime);
|
||||||
|
y = y + 30;
|
||||||
|
|
||||||
|
String column[] = {"Název", "Stav", "Admin", "Rychlost", "Typ", "Poslední změna"};
|
||||||
|
tableModel = new DefaultTableModel(column, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
//all cells false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ifaceTable = new JTable(tableModel);
|
||||||
|
ifaceTable.getTableHeader().setReorderingAllowed(false); // Zakáže přeskupování sloupců
|
||||||
|
ifaceTable.getTableHeader().setResizingAllowed(false); // Zakáže změnu velikosti sloupců
|
||||||
|
ifaceTable.getColumnModel().getColumn(0).setPreferredWidth(150); // Sloupec 0 bude mít šířku 100 px
|
||||||
|
ifaceTable.getColumnModel().getColumn(1).setPreferredWidth(40); // Sloupec 1 bude mít šířku 100 px
|
||||||
|
ifaceTable.getColumnModel().getColumn(2).setPreferredWidth(40); // Sloupec 2 bude mít šířku 100 px
|
||||||
|
ifaceTable.getColumnModel().getColumn(3).setPreferredWidth(50); // Sloupec 3 bude mít šířku 100 px
|
||||||
|
ifaceTable.getColumnModel().getColumn(4).setPreferredWidth(60); // Sloupec 4 bude mít šířku 100 px
|
||||||
|
//ifaceTable.getColumnModel().getColumn(5).setPreferredWidth(100); // Sloupec 5 bude mít šířku 100 px
|
||||||
|
|
||||||
|
JScrollPane tableScroll = new JScrollPane(ifaceTable);
|
||||||
|
tableScroll.setBounds(x1, y, (this.getWidth() - x1 * 3), 200);
|
||||||
|
this.add(tableScroll);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void snmpRequest() {
|
||||||
|
Object[] data = {frameName, this.obj};
|
||||||
|
NettyClient.send(Message.SNMP_OBJECT_INFO, data);
|
||||||
|
NettyClient.send(Message.SNMP_OBJECT_INTERFACE, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name.setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesc(String desc) {
|
||||||
|
this.description.setText(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUptime(String uptime) {
|
||||||
|
this.uptime.setText(uptime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVendor(String vendor) {
|
||||||
|
this.vendor.setText(vendor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterface(List<Interface> iface) {
|
||||||
|
for (Interface i : iface) {
|
||||||
|
Object[] d = {
|
||||||
|
i.getDescription(),
|
||||||
|
i.getOperStatus(),
|
||||||
|
i.getAdminStatus(),
|
||||||
|
i.getSpeed(),
|
||||||
|
i.getType(),
|
||||||
|
i.getLastChangeTime()};
|
||||||
|
tableModel.addRow(d);
|
||||||
|
}
|
||||||
|
ifaceTable.revalidate();
|
||||||
|
ifaceTable.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,24 +120,33 @@ class TabServices extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWinboxPort() {
|
public String getWinboxPort() {
|
||||||
|
if (validatePort(portWinbox.getText())) {
|
||||||
return portWinbox.getText();
|
return portWinbox.getText();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSsh() {
|
public boolean isSsh() {
|
||||||
return sshBox.isSelected();
|
return sshBox.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSshPort() {
|
public String getSshPort() {
|
||||||
|
if (validatePort(portSsh.getText())) {
|
||||||
return portSsh.getText();
|
return portSsh.getText();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isWeb() {
|
public boolean isWeb() {
|
||||||
return wwwBox.isSelected();
|
return wwwBox.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWebPort() {
|
public String getWebPort() {
|
||||||
|
if (validatePort(portWww.getText())) {
|
||||||
return portWww.getText();
|
return portWww.getText();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getWebVersion() {
|
public int getWebVersion() {
|
||||||
return wwwVerzeComboBox.getSelectedIndex();
|
return wwwVerzeComboBox.getSelectedIndex();
|
||||||
|
|
@ -148,18 +157,35 @@ class TabServices extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTelnetPort() {
|
public String getTelnetPort() {
|
||||||
|
if (validatePort(portTelnet.getText())) {
|
||||||
return portTelnet.getText();
|
return portTelnet.getText();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSms() {
|
public boolean isSms() {
|
||||||
return smstBox.isSelected();
|
return smstBox.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSmsPort() {
|
public String getSmsPort() {
|
||||||
|
if (validatePort(portSms.getText())) {
|
||||||
return portSms.getText();
|
return portSms.getText();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSmsVersion() {
|
public int getSmsVersion() {
|
||||||
return smsVerzeComboBox.getSelectedIndex();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue