Compare commits

..

No commits in common. "465879cdae335cef72336318f973ddd683d4bfcf" and "27f3734ab02eb52f27159b2825d20f713f496eb9" have entirely different histories.

4 changed files with 29 additions and 72 deletions

View File

@ -3,6 +3,8 @@ package jnet.client;
import jnet.client.gui.Tray;
import jnet.client.gui.Window;
import jnet.client.network.NettyClient;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

View File

@ -147,7 +147,6 @@ public class ClientMessageParser {
MapObject new_mo = (MapObject) msg.getMsg();
// pridat do seznamu
Client.mapObject.add(new_mo);
break;
case Message.REMOVE_OBJECT:

View File

@ -20,7 +20,7 @@ public class EventsPanel extends JPanel {
int limit = 50;
String column[] = {"Začátek", "Konec", "Délka", "Stav", "Mapa", "Zařízení"};
String column[] = {"Začátek", "Konec", "Stav", "Mapa", "Zařízení"};
DefaultTableModel tableModel = new DefaultTableModel(column, 0) {
@Override
@ -32,8 +32,8 @@ public class EventsPanel extends JPanel {
Collections.sort(Client.events, new EventComparator());
Collections.reverse(Client.events);
if (limit > Client.events.size()) {
if (limit > Client.events.size()){
limit = Client.events.size();
}
@ -42,7 +42,6 @@ public class EventsPanel extends JPanel {
Object[] d = {
getDate(Client.events.get(i).getStart()),
getDate(Client.events.get(i).getEnd()),
getDuration(Client.events.get(i).getStart(), Client.events.get(i).getEnd()),
Client.events.get(i).getDescription(),
info[0],
info[1]};
@ -65,29 +64,16 @@ public class EventsPanel extends JPanel {
return "";
}
private String getDuration(long startTime, long endTime) {
if (endTime != 0) {
long difference = endTime - startTime;
// převod na sekundy, minuty, hodiny
long seconds = difference / 1000;
long minutes = difference / (1000 * 60);
long hours = difference / (1000 * 60 * 60);
SimpleDateFormat ft = new SimpleDateFormat("HH:mm:ss");
return hours + "h " + minutes + "m " + seconds + "s";
}
return "";
}
private String[] getObjetInfo(int id) {
for (MapObject mapObject : Client.mapObject) {
if (mapObject.getId() == id) {
for (Map map : Client.maps) {
if (map.getId() == mapObject.getMap()) {
String[] data = {map.getName(), mapObject.getName()};
return data;
}
ListIterator<Map> iteratorMap = Client.maps.listIterator();
ListIterator<MapObject> iteratorMapObject = Client.mapObject.listIterator();
while (iteratorMap.hasNext()) {
Map map = iteratorMap.next();
while (iteratorMapObject.hasNext()) {
MapObject obj = iteratorMapObject.next();
if (obj.getId() == id) {
String[] data = {map.getName(), obj.getName()};
return data;
}
}
}

View File

@ -10,7 +10,6 @@ import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
@ -19,7 +18,6 @@ import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableModel;
import jnet.lib.LogFile;
import jnet.lib.Message;
import jnet.lib.object.SnmpProfile;
import jnet.lib.object.User;
@ -56,7 +54,7 @@ public class ServerSettingsPanel extends JTabbedPane {
JPanel panel = new JPanel();
panel.setLayout(null);
int x1 = 80;
int x2 = 150;
@ -64,53 +62,44 @@ public class ServerSettingsPanel extends JTabbedPane {
pingLabel.setFont(pingLabel.getFont().deriveFont(20f));
pingLabel.setBounds(20, 20, 150, 25);
panel.add(pingLabel);
JTextField repeateField = new JTextField(String.valueOf(Client.serverConfig.getPingAttempt()));
repeateField.setBounds(x1, 60, 50, 25);
panel.add(repeateField);
JLabel repeateLabel = new JLabel("Opakovat ping každých ... sekund");
repeateLabel.setBounds(x2, 60, 300, 25);
panel.add(repeateLabel);
JTextField pokusuField = new JTextField(String.valueOf(Client.serverConfig.getPingAttempt()));
pokusuField.setBounds(x1, 100, 50, 25);
pokusuField.setBounds(x1, 60, 50, 25);
panel.add(pokusuField);
JLabel pokusuLabel = new JLabel("Počet pokusů před vyhodnocenim offline");
pokusuLabel.setBounds(x2, 100, 300, 25);
pokusuLabel.setBounds(x2, 60, 300, 25);
panel.add(pokusuLabel);
JTextField timeoutField = new JTextField(String.valueOf(Client.serverConfig.getPingTimeout()));
timeoutField.setBounds(x1, 140, 50, 25);
timeoutField.setBounds(x1, 100, 50, 25);
panel.add(timeoutField);
JLabel timeoutLabel = new JLabel("Úroveň timeout (s)");
timeoutLabel.setBounds(x2, 140, 300, 25);
JLabel timeoutLabel = new JLabel("Úroveň timeout (ms)");
timeoutLabel.setBounds(x2, 100, 300, 25);
panel.add(timeoutLabel);
JTextField pokusuNestField = new JTextField(String.valueOf(Client.serverConfig.getInstabilityAttempt()));
pokusuNestField.setBounds(x1, 180, 50, 25);
pokusuNestField.setBounds(x1, 140, 50, 25);
panel.add(pokusuNestField);
JLabel pokusuNestLabel = new JLabel("Počet pokusů před vyhodnocením nestability");
pokusuNestLabel.setBounds(x2, 180, 300, 25);
pokusuNestLabel.setBounds(x2, 140, 300, 25);
panel.add(pokusuNestLabel);
JTextField nestField = new JTextField(String.valueOf(Client.serverConfig.getInstabilityLimit()));
nestField.setBounds(x1, 220, 50, 25);
nestField.setBounds(x1, 180, 50, 25);
panel.add(nestField);
JLabel nestLabel = new JLabel("Úroveň nestability (s)");
nestLabel.setBounds(x2, 220, 300, 25);
JLabel nestLabel = new JLabel("Úroveň nestability (ms)");
nestLabel.setBounds(x2, 180, 300, 25);
panel.add(nestLabel);
JButton button = new JButton("Uložit");
button.setAlignmentX(Component.CENTER_ALIGNMENT);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Client.serverConfig.setPingRepeat(Integer.valueOf(repeateField.getText()));
Client.serverConfig.setPingAttempt(Integer.valueOf(pokusuField.getText()));
Client.serverConfig.setPingTimeout(Integer.valueOf(timeoutField.getText()));
Client.serverConfig.setInstabilityAttempt(Integer.valueOf(pokusuNestField.getText()));
@ -118,28 +107,9 @@ public class ServerSettingsPanel extends JTabbedPane {
NettyClient.send(Message.SERVER_CONFIG, Client.serverConfig);
}
});
button.setBounds(x1, 300, 100, 40);
button.setBounds(x1, 220, 100, 40);
panel.add(button);
JButton buttonRestart = new JButton("Restartovat server");
//buttonRestart.setAlignmentX(Component.CENTER_ALIGNMENT);
buttonRestart.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int result = JOptionPane.showConfirmDialog(null,
"Opravdu chceš pokračovat?",
"Restart serveru",
JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
LogFile.printInfo("Odeslan pozadavek na restart serveru");
NettyClient.send(Message.RESTART, null);
}
}
});
buttonRestart.setBounds(x1+200, 300, 150, 40);
panel.add(buttonRestart);
return new JScrollPane(panel);
}