/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pm.Server; import eric.FileTools; import eric.GUI.ZDialog.ZButton; import eric.GUI.ZDialog.ZCheckBox; import eric.GUI.ZDialog.ZDialog; import eric.GUI.ZDialog.ZSep; import eric.GUI.ZDialog.ZTextFieldAndLabel; import eric.GUI.ZDialog.ZTools; import eric.GUI.window.tab_main_panel; import eric.GUI.windowComponent; import eric.JZirkelCanvas; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.RoundRectangle2D; import java.net.InetAddress; import java.net.UnknownHostException; import javax.swing.JLabel; import rene.gui.Global; /** * * @author PM */ public class ServerControlPanel extends ZDialog { private JLabel Jip, Jreceive, Jsend_to; private ZTextFieldAndLabel Zport; private ZButton Zconnect, Zsend, Zsend_all; private ZCheckBox Zpoint, Zline, Zcircle, Zfunction, Zreal_time_view, Zcollaborative; private boolean Point = true, Line = true, Circle = true, Function = true; private InetAddress LocaleAdresse ; private int PORT = 2357, NB_MAX = 20, H; private ZSep sep = new ZSep(75), sep2 = new ZSep(75), sep3 = new ZSep(75); private Server server = null; private boolean reduced = false, isServerRunning = false; private String clients[][] = null; //clients[i][0] = login, clients[i][1] = ip, clients[i][2] = real_time_view private boolean refresh = false; //to avoid an infinite loop un paint private boolean collaboration = false; public ServerControlPanel(){ super(Global.Loc("network.server.title"), 3, 90, 200, 300, true, true); LWIDTH = 40; BWIDTH = 80; H = D_HEIGHT; clients = new String[NB_MAX][3]; for(int i=0; i = "+clients[i][2]+"\n", i); } } else { this.setSelected(collaboration); } } }; Zreal_time_view.setEnabled(false); Jsend_to = new JLabel(); Jsend_to.setText(Global.Loc("network.server.send")); Zsend = new ZButton(Global.Loc("network.client.name")) { @Override public void action() { if(server!=null) { String tab_name = tab_main_panel.getActiveBtn().getTabName(); int i = get_client_index(tab_name); try { server.send(FileTools.getCurrentFileSource(), i); this.pressed(this); } catch(Exception ex){} } } }; Zsend.setEnabled(false); Zsend_all = new ZButton(Global.Loc("network.server.all")) { @Override public void action() { try { server.send(FileTools.getCurrentFileSource()); this.pressed(this); } catch(Exception ex){} } }; Zsend_all.setEnabled(false); Zcollaborative = new ZCheckBox("Travail collaboratif (β)", false) { @Override public synchronized void action(){ int i = 0; if(server==null){ this.setSelected(false); } else { if(collaboration = this.isSelected()) { //it is an = try { String src = FileTools.getCurrentFileSource(); server.send(src); //the construction is sent to everyone //on se positionne sur l'onglet Global int n = tab_main_panel.getBTNSsize(); while(i = "+collaboration+"\n"); Zreal_time_view.setEnabled(!collaboration || !tab_main_panel.getActiveBtn().getTabName().equals("Global")); Zreal_time_view.setSelected(collaboration); for(i=0; i"); server.kill(); } isServerRunning = false; //server = null; } public boolean get_collaboration() { return collaboration; } @Override public void send(String msg){ server.send(msg); } public void send_minus(String msg, String ip) { for(int i=0; i