cteni SNMPT informaci o objektu a jejich rozhranich
parent
c28c2dfe19
commit
4b7d0e3e8f
|
|
@ -43,55 +43,54 @@ public class Client {
|
|||
|
||||
|
||||
LogFile.clear();
|
||||
LogFile.printInfo("---------------------------------------------");
|
||||
LogFile.printInfo(" jNet Client ");
|
||||
LogFile.printInfo(" Version: " + CLIENT_VERSION + " (" + BuilddDate.get() + ")");
|
||||
LogFile.printInfo("---------------------------------------------");
|
||||
LogFile.printInfo("");
|
||||
|
||||
///
|
||||
/// load config
|
||||
///
|
||||
LogFile.printInfo("Loading config ...");
|
||||
try {
|
||||
// Načtení existující konfigurace, pokud soubor existuje
|
||||
config = new PropertiesManager("config.properties");
|
||||
config.load();
|
||||
LogFile.printInfo(" successfully");
|
||||
} catch (PropertiesManager.FileException | PropertiesManager.ConfigException ex) {
|
||||
LogFile.printErr(" fail. " + ex.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
///
|
||||
/// debug rezim ?
|
||||
///
|
||||
if (config.getBoolean("debug")) {
|
||||
LogFile.setDebug(true);
|
||||
LogFile.printDebug("Debug mode on");
|
||||
}
|
||||
|
||||
///
|
||||
/// okno
|
||||
///
|
||||
///
|
||||
/// tray icon
|
||||
///
|
||||
new Tray().createAndShowTray();
|
||||
|
||||
///
|
||||
/// spustit minimalozovane ?
|
||||
///
|
||||
if (config.getBoolean("start_minimalized")) {
|
||||
okno.setVisible(false);
|
||||
} else {
|
||||
okno.setVisible(true);
|
||||
}
|
||||
|
||||
// Spuštění klienta v novém vlákně
|
||||
NettyClient client = new NettyClient(config.getString("server"), config.getInt("port"));
|
||||
clientThread = new Thread(client);
|
||||
clientThread.start();
|
||||
LogFile.printInfo("---------------------------------------------");
|
||||
LogFile.printInfo(" jNet Client ");
|
||||
LogFile.printInfo(" Version: " + CLIENT_VERSION + " (" + BuilddDate.get() + ")");
|
||||
LogFile.printInfo("---------------------------------------------");
|
||||
LogFile.printInfo("");
|
||||
|
||||
///
|
||||
/// load config
|
||||
///
|
||||
LogFile.printInfo("Loading config ...");
|
||||
try {
|
||||
// Načtení existující konfigurace, pokud soubor existuje
|
||||
config = new PropertiesManager("config.properties");
|
||||
config.load();
|
||||
LogFile.printInfo(" successfully");
|
||||
} catch (PropertiesManager.FileException | PropertiesManager.ConfigException ex) {
|
||||
LogFile.printErr(" fail. " + ex.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
///
|
||||
/// debug rezim ?
|
||||
///
|
||||
if (config.getBoolean("debug")) {
|
||||
LogFile.setDebug(true);
|
||||
LogFile.printDebug("Debug mode on");
|
||||
}
|
||||
|
||||
///
|
||||
/// tray icon
|
||||
///
|
||||
new Tray().createAndShowTray();
|
||||
|
||||
///
|
||||
/// spustit minimalozovane ?
|
||||
///
|
||||
if (config.getBoolean("start_minimalized")) {
|
||||
okno.setVisible(false);
|
||||
} else {
|
||||
okno.setVisible(true);
|
||||
}
|
||||
|
||||
// Spuštění klienta v novém vlákně
|
||||
NettyClient client = new NettyClient(config.getString("server"), config.getInt("port"));
|
||||
clientThread = new Thread(client);
|
||||
clientThread.start();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package jnet.client;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.JOptionPane;
|
||||
import jnet.client.gui.UIUpdater;
|
||||
|
|
@ -16,6 +17,8 @@ import jnet.lib.object.OnlineClients;
|
|||
import jnet.lib.object.ServerConfig;
|
||||
import jnet.lib.object.SnmpProfile;
|
||||
import jnet.lib.object.User;
|
||||
import jnet.lib.snmp.DeviceInfo;
|
||||
import jnet.lib.snmp.Interface;
|
||||
|
||||
public class ClientMessageParser {
|
||||
|
||||
|
|
@ -45,6 +48,8 @@ public class ClientMessageParser {
|
|||
handlers.put(Message.USER_EDIT, ClientMessageParser::handleUserEdit);
|
||||
handlers.put(Message.DELETE_LOG, ClientMessageParser::handleDeleteLog);
|
||||
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) {
|
||||
|
|
@ -209,5 +214,18 @@ public class ClientMessageParser {
|
|||
private static void handleServerConfig(Message msg) {
|
||||
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;
|
||||
|
||||
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 {
|
||||
|
||||
|
|
@ -29,5 +33,27 @@ public class UIUpdater {
|
|||
MapView.updateMapView();
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ public class Window extends JFrame {
|
|||
|
||||
public Window() {
|
||||
super(Client.APP_NAME); //titulek okna
|
||||
|
||||
//identifikator okna
|
||||
this.setName("mainWindow");
|
||||
|
||||
Dimension d = new Dimension(1024, 800);
|
||||
this.setPreferredSize(d);
|
||||
|
|
@ -36,7 +39,7 @@ public class Window extends JFrame {
|
|||
this.setLocationRelativeTo(null);
|
||||
|
||||
try {
|
||||
this.setIconImage(ImageIO.read(new File("img/app.png")));
|
||||
this.setIconImage(ImageIO.read(getClass().getResourceAsStream("/img/app.png")));
|
||||
} catch (IOException ex) {
|
||||
LogFile.printErr("APP icon exception");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ package jnet.client.gui.dialog.object;
|
|||
import java.awt.BorderLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.List;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
|
@ -14,18 +13,27 @@ import jnet.client.network.NettyClient;
|
|||
import jnet.lib.Message;
|
||||
import jnet.lib.Status;
|
||||
import jnet.lib.object.MapObject;
|
||||
|
||||
import jnet.lib.snmp.DeviceInfo;
|
||||
import jnet.lib.snmp.Interface;
|
||||
|
||||
public class ObjectDialog extends JFrame {
|
||||
|
||||
|
||||
private MapObject obj;
|
||||
private int mapId;
|
||||
private Boolean newObject;
|
||||
|
||||
private TabInfo tabInfo;
|
||||
private TabSettings tabSettings;
|
||||
private TabServices tabServices;
|
||||
private TabEvents tabEvents;
|
||||
|
||||
public ObjectDialog(MapObject obj) {
|
||||
this.obj = obj;
|
||||
this.mapId = obj.getMap();
|
||||
this.newObject = false;
|
||||
|
||||
// identifikator okna
|
||||
this.setName("object_detail_" + obj.getId());
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
@ -35,134 +43,137 @@ public class ObjectDialog extends JFrame {
|
|||
this.newObject = newObject;
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
private void init() {
|
||||
if (newObject) {
|
||||
setTitle("Nový objekt");
|
||||
} else {
|
||||
setTitle(obj.getName());
|
||||
}
|
||||
|
||||
setSize(600, 520);
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
setAlwaysOnTop(false);
|
||||
setResizable(false);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
|
||||
|
||||
if (newObject) {
|
||||
setTitle("Nový objekt");
|
||||
} else {
|
||||
setTitle(obj.getName());
|
||||
}
|
||||
|
||||
setSize(600, 520);
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
setAlwaysOnTop(false);
|
||||
setResizable(false);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
|
||||
// JScrollPane tabNastaveni = new JScrollPane(tabNastaveni(),
|
||||
// JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
TabInfo tabInfo = new TabInfo();
|
||||
TabSettings tabSettings = new TabSettings(obj, newObject);
|
||||
TabServices tabServices = new TabServices(obj, newObject);
|
||||
TabEvents tabEvents = new TabEvents(obj);
|
||||
|
||||
tabbedPane.addTab("Informace", tabInfo);
|
||||
tabbedPane.addTab("Nastaveni", tabSettings);
|
||||
tabbedPane.addTab("Služby", tabServices);
|
||||
tabbedPane.addTab("Události", tabEvents);
|
||||
//tabbedPane.addTab("Sondy", tabSondy());
|
||||
tabInfo = new TabInfo(this.getName(), obj);
|
||||
tabSettings = new TabSettings(obj, newObject);
|
||||
tabServices = new TabServices(obj, newObject);
|
||||
tabEvents = new TabEvents(obj);
|
||||
|
||||
// pokud se jedna o novy objekt
|
||||
if (newObject) {
|
||||
tabbedPane.setSelectedIndex(1); // prepne na kartu nastaveni
|
||||
tabbedPane.setEnabledAt(0, false); // vypne kartu informace
|
||||
tabbedPane.setEnabledAt(3, false); // vypne kartu udalosti
|
||||
}
|
||||
|
||||
add(tabbedPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
JButton save = new JButton("Ulozit");
|
||||
save.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// kontrola chyb
|
||||
String nazev = tabSettings.getName();
|
||||
if (nazev == null) {
|
||||
return;
|
||||
}
|
||||
String ip = tabSettings.getIp();
|
||||
if (ip == null) {
|
||||
return;
|
||||
}
|
||||
// ulozeni do objektu
|
||||
obj.setMap(mapId);
|
||||
obj.setName(nazev);
|
||||
obj.setIp(ip);
|
||||
obj.setUser(tabSettings.getUser());
|
||||
obj.setPassword(new String(tabSettings.getPassword()));
|
||||
obj.setObjectType(Client.objectType.get(tabSettings.getObjType()).getId());
|
||||
obj.setSnmpProfile(Client.snmpProfile.get(tabSettings.getSnmpProfile()).getId());
|
||||
obj.setActive(tabSettings.isActive());
|
||||
obj.setDescription(tabSettings.getDesc());
|
||||
obj.setLocation(tabSettings.getLoc());
|
||||
// TODO validaci portu
|
||||
obj.setWinbox(tabServices.isWinbox());
|
||||
obj.setWinboxPort(tabServices.getWinboxPort());
|
||||
obj.setSsh(tabServices.isSsh());
|
||||
obj.setSshPort(tabServices.getSshPort());
|
||||
obj.setWeb(tabServices.isWeb());
|
||||
obj.setWebPort(tabServices.getWebPort());
|
||||
obj.setWebVerze(tabServices.getWebVersion());
|
||||
obj.setTelnet(tabServices.isTelnet());
|
||||
obj.setTelnetPort(tabServices.getTelnetPort());
|
||||
obj.setSms(tabServices.isSms());
|
||||
obj.setSmsPort(tabServices.getSmsPort());
|
||||
obj.setSmsVerze(tabServices.getSmsVersion());
|
||||
|
||||
if (!obj.isActive() || newObject) {
|
||||
obj.setStatus(Status.NA);
|
||||
}
|
||||
tabbedPane.addTab("Informace", tabInfo);
|
||||
tabbedPane.addTab("Nastaveni", tabSettings);
|
||||
tabbedPane.addTab("Služby", tabServices);
|
||||
tabbedPane.addTab("Události", tabEvents);
|
||||
//tabbedPane.addTab("Sondy", tabSondy());
|
||||
|
||||
// pokud se jedna o novy objekt
|
||||
if (newObject) {
|
||||
tabbedPane.setSelectedIndex(1); // prepne na kartu nastaveni
|
||||
tabbedPane.setEnabledAt(0, false); // vypne kartu informace
|
||||
tabbedPane.setEnabledAt(3, false); // vypne kartu udalosti
|
||||
}
|
||||
|
||||
add(tabbedPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel pane = new JPanel();
|
||||
JButton save = new JButton("Ulozit");
|
||||
save.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// kontrola chyb
|
||||
String nazev = tabSettings.getName();
|
||||
if (nazev == null) {
|
||||
return;
|
||||
}
|
||||
String ip = tabSettings.getIp();
|
||||
if (ip == null) {
|
||||
return;
|
||||
}
|
||||
// ulozeni do objektu
|
||||
obj.setMap(mapId);
|
||||
obj.setName(nazev);
|
||||
obj.setIp(ip);
|
||||
obj.setUser(tabSettings.getUser());
|
||||
obj.setPassword(new String(tabSettings.getPassword()));
|
||||
obj.setObjectType(Client.objectType.get(tabSettings.getObjType()).getId());
|
||||
obj.setSnmpProfile(Client.snmpProfile.get(tabSettings.getSnmpProfile()).getId());
|
||||
obj.setActive(tabSettings.isActive());
|
||||
obj.setDescription(tabSettings.getDesc());
|
||||
obj.setLocation(tabSettings.getLoc());
|
||||
|
||||
obj.setWinbox(tabServices.isWinbox());
|
||||
String winboxPort = tabServices.getWinboxPort();
|
||||
if (winboxPort == null) {
|
||||
return;
|
||||
}
|
||||
obj.setWinboxPort(winboxPort);
|
||||
obj.setSsh(tabServices.isSsh());
|
||||
String sshPort = tabServices.getSshPort();
|
||||
if (sshPort == null) {
|
||||
return;
|
||||
}
|
||||
obj.setSshPort(sshPort);
|
||||
obj.setWeb(tabServices.isWeb());
|
||||
String webPort = tabServices.getWebPort();
|
||||
if (webPort == null) {
|
||||
return;
|
||||
}
|
||||
obj.setWebPort(webPort);
|
||||
obj.setWebVerze(tabServices.getWebVersion());
|
||||
obj.setTelnet(tabServices.isTelnet());
|
||||
String telnetPort = tabServices.getTelnetPort();
|
||||
if (telnetPort == null) {
|
||||
return;
|
||||
}
|
||||
obj.setTelnetPort(telnetPort);
|
||||
obj.setSms(tabServices.isSms());
|
||||
String smsPort = tabServices.getSmsPort();
|
||||
if (smsPort == null) {
|
||||
return;
|
||||
}
|
||||
obj.setSmsPort(smsPort);
|
||||
obj.setSmsVerze(tabServices.getSmsVersion());
|
||||
|
||||
if (!obj.isActive() || newObject) {
|
||||
obj.setStatus(Status.NA);
|
||||
}
|
||||
// ArrayList<SnmpProbe> probe = new ArrayList<>();
|
||||
// if (!newObject) {
|
||||
// probe.addAll(obj.getSnmpProbe());
|
||||
// }
|
||||
// obj.setSnmpProbe(probe);
|
||||
|
||||
if (newObject) {
|
||||
NettyClient.send(Message.ADD_OBJECT, obj);
|
||||
} else {
|
||||
NettyClient.send(Message.UPDATE_OBJECT, obj);
|
||||
}
|
||||
if (newObject) {
|
||||
NettyClient.send(Message.ADD_OBJECT, obj);
|
||||
} else {
|
||||
NettyClient.send(Message.UPDATE_OBJECT, obj);
|
||||
}
|
||||
|
||||
// zavreni dialogu
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
pane.add(save);
|
||||
|
||||
JButton cancel = new JButton("Zrusit");
|
||||
cancel.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
pane.add(cancel);
|
||||
|
||||
add(pane, BorderLayout.PAGE_END);
|
||||
|
||||
// zavreni dialogu
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
pane.add(save);
|
||||
|
||||
JButton cancel = new JButton("Zrusit");
|
||||
cancel.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
pane.add(cancel);
|
||||
|
||||
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) {
|
||||
switch (status) {
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import javax.swing.JLabel;
|
||||
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{
|
||||
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() {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,52 +114,78 @@ class TabServices extends JPanel {
|
|||
smsVerzeComboBox.setSelectedIndex(obj.getSmsVerze());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isWinbox() {
|
||||
return winboxBox.isSelected();
|
||||
}
|
||||
|
||||
|
||||
public String getWinboxPort() {
|
||||
return portWinbox.getText();
|
||||
if (validatePort(portWinbox.getText())) {
|
||||
return portWinbox.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSsh() {
|
||||
return sshBox.isSelected();
|
||||
}
|
||||
|
||||
|
||||
public String getSshPort() {
|
||||
return portSsh.getText();
|
||||
if (validatePort(portSsh.getText())) {
|
||||
return portSsh.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isWeb() {
|
||||
return wwwBox.isSelected();
|
||||
}
|
||||
|
||||
|
||||
public String getWebPort() {
|
||||
return portWww.getText();
|
||||
if (validatePort(portWww.getText())) {
|
||||
return portWww.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public int getWebVersion() {
|
||||
return wwwVerzeComboBox.getSelectedIndex();
|
||||
}
|
||||
|
||||
|
||||
public boolean isTelnet() {
|
||||
return telnetBox.isSelected();
|
||||
}
|
||||
|
||||
|
||||
public String getTelnetPort() {
|
||||
return portTelnet.getText();
|
||||
if (validatePort(portTelnet.getText())) {
|
||||
return portTelnet.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isSms() {
|
||||
return smstBox.isSelected();
|
||||
}
|
||||
|
||||
|
||||
public String getSmsPort() {
|
||||
return portSms.getText();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue