Make first real commit: copy of CaRMetal 4.2.8
This commit is contained in:
parent
002acfc88e
commit
c312811084
1120 changed files with 226843 additions and 1 deletions
38
pm/Client/Client.java
Normal file
38
pm/Client/Client.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package pm.Client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PM
|
||||
*/
|
||||
public class Client implements Runnable {
|
||||
|
||||
private String IP = null, login = null;
|
||||
private int PORT;
|
||||
private Socket socket = null;
|
||||
private ConnectionControlPanel ccp = null;
|
||||
|
||||
public Client(String name, String IP, int PORT, ConnectionControlPanel ccp) {
|
||||
this.login = name;
|
||||
this.IP = IP;
|
||||
this.PORT = PORT;
|
||||
this.ccp = ccp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
socket = new Socket(IP, PORT);
|
||||
new Thread(new Connexion(socket, login)).start();
|
||||
ccp.doClose();
|
||||
} catch (IOException e){
|
||||
System.out.println("Erreur de connexion (Client)");
|
||||
}
|
||||
}
|
||||
}
|
269
pm/Client/ClientNetworkTools.java
Normal file
269
pm/Client/ClientNetworkTools.java
Normal file
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package pm.Client;
|
||||
|
||||
import eric.FileTools;
|
||||
import eric.GUI.ZDialog.ZButton;
|
||||
import eric.GUI.ZDialog.ZDialog;
|
||||
import eric.GUI.ZDialog.ZTextFieldAndLabel;
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.JZirkelCanvas;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import rene.gui.Global;
|
||||
import rene.util.MyVector;
|
||||
import rene.util.xml.XmlWriter;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
import rene.zirkel.constructors.ObjectConstructor;
|
||||
import rene.zirkel.objects.ConstructionObject;
|
||||
import rene.zirkel.objects.FunctionObject;
|
||||
import rene.zirkel.objects.PlumbObject;
|
||||
import rene.zirkel.objects.PointObject;
|
||||
import rene.zirkel.objects.PrimitiveCircleObject;
|
||||
import rene.zirkel.objects.PrimitiveLineObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PM
|
||||
*/
|
||||
public class ClientNetworkTools extends ZDialog{
|
||||
|
||||
private ZTextFieldAndLabel targetslist;
|
||||
private ZButton send_work, send_objects;
|
||||
private Communication com;
|
||||
private int FWIDTH = 240;
|
||||
private boolean point, line, circle, function, real_time;
|
||||
|
||||
public ClientNetworkTools(Communication com){
|
||||
super("Network Tools", 0, 0, 366, 70, false, false);
|
||||
//BWIDTH = 80;
|
||||
this.com = com;
|
||||
addContent();
|
||||
}
|
||||
|
||||
public void init(int w, int h) {
|
||||
int x = (w-D_WIDTH)/2;
|
||||
int y = h-D_HEIGHT-4;
|
||||
setBounds(x, y, D_WIDTH, D_HEIGHT);
|
||||
}
|
||||
|
||||
private void addContent(){
|
||||
send_work = new ZButton(Global.Loc("network.client.sendwork")) {
|
||||
|
||||
@Override
|
||||
public void action(){
|
||||
try {
|
||||
String str = PaletteManager.geomSelectedIcon(); //(*)
|
||||
PaletteManager.deselectgeomgroup(); //(*)
|
||||
com.send(FileTools.getCurrentFileSource());
|
||||
this.pressed(this);
|
||||
PaletteManager.setSelected_with_clic(str, true); //(*)
|
||||
|
||||
/* these three lines are a trick to prevent
|
||||
* the cursor to be placed in the next component,
|
||||
* which is the field targetslist
|
||||
* A more elegant solution have to be found..
|
||||
*/
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Erreur d'envoi");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
targetslist = new ZTextFieldAndLabel(Global.Loc("job.gui.targets"), "", 0, CHEIGHT) {
|
||||
|
||||
@Override
|
||||
public void actionMouse() {
|
||||
PaletteManager.deselectgeomgroup();
|
||||
ZirkelCanvas zc = JZirkelCanvas.getCurrentZC();
|
||||
|
||||
zc.setTool(new SelectionTool((ClientNetworkTools) this.getParent(), this));
|
||||
zc.showStatus("Select Objects");
|
||||
|
||||
if(!this.getText().equals("")){
|
||||
String[] names = this.getText().split(";");
|
||||
for(String name : names){
|
||||
ConstructionObject o = zc.getConstruction().find(name);
|
||||
if(o!=null){
|
||||
o.setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
zc.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionKey(KeyEvent k) {
|
||||
//A programmer
|
||||
}
|
||||
};
|
||||
|
||||
send_objects = new ZButton(Global.Loc("network.client.share")) {
|
||||
|
||||
@Override
|
||||
public void action(){
|
||||
if(!targetslist.getText().equals("")){
|
||||
String[] names = targetslist.getText().split(";");
|
||||
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
|
||||
XmlWriter xml = new XmlWriter(new PrintWriter(new OutputStreamWriter(bout), true));
|
||||
xml.printXml();
|
||||
|
||||
xml.startTagNewLine("Objects");
|
||||
for(String name : names){
|
||||
ConstructionObject o = JZirkelCanvas.getCurrentZC().getConstruction().find(name);
|
||||
/*
|
||||
Enumeration e = o.depending();
|
||||
while(e.hasMoreElements()){
|
||||
((ConstructionObject) e.nextElement()).save(xml);
|
||||
}
|
||||
o.save(xml);
|
||||
*/
|
||||
|
||||
ArrayList<ConstructionObject> list = Collections.list(o.depending());
|
||||
find_all_depending(list, xml);
|
||||
o.save(xml);
|
||||
o.setSelected(false);
|
||||
}
|
||||
JZirkelCanvas.getCurrentZC().repaint();
|
||||
xml.endTagNewLine("Objects");
|
||||
//cc.send(out.toString("utf-8"));
|
||||
com.send("<Global>\n"+bout.toString());
|
||||
targetslist.setText("");
|
||||
this.pressed(this);
|
||||
//System.out.println(out.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.add(send_work);
|
||||
this.add(targetslist);
|
||||
this.add(send_objects);
|
||||
|
||||
fixComponents();
|
||||
}
|
||||
|
||||
public XmlWriter find_all_depending(ArrayList<ConstructionObject> list, XmlWriter xml) {
|
||||
ArrayList<ConstructionObject> l ;
|
||||
|
||||
for(int i = 0; i<list.size(); i++) {
|
||||
l = Collections.list(list.get(i).depending());
|
||||
xml = find_all_depending(l, xml);
|
||||
|
||||
list.get(i).save(xml);
|
||||
}
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixComponents(){
|
||||
send_work.setBounds((D_WIDTH-2*BWIDTH)/2, MARGINTOP1, 2*BWIDTH, CHEIGHT);
|
||||
targetslist.setBounds(MARGINW, MARGINTOP2, FWIDTH, CHEIGHT);
|
||||
send_objects.setBounds(FWIDTH+2*MARGINW, MARGINTOP2, BWIDTH, CHEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doClose() {
|
||||
com.close();
|
||||
JZirkelCanvas.getCurrentZC().remove(this);
|
||||
JZirkelCanvas.getCurrentZC().repaint();
|
||||
JZirkelCanvas.getCurrentZC().set_cnt(null);
|
||||
}
|
||||
|
||||
public void set_accepted_object(String obj, boolean bol){
|
||||
if(obj.equals("point")){
|
||||
point = bol;
|
||||
} else if(obj.equals("line")){
|
||||
line = bol;
|
||||
} else if(obj.equals("circle")){
|
||||
circle = bol;
|
||||
} else if(obj.equals("function")){
|
||||
function = bol;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean get_accepted_object(String obj){
|
||||
if(obj.equals("point")){
|
||||
return point;
|
||||
} else if(obj.equals("line")){
|
||||
return line;
|
||||
} else if(obj.equals("circle")){
|
||||
return circle;
|
||||
} else if(obj.equals("function")){
|
||||
return function;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void set_real_time(boolean bol){
|
||||
real_time = bol;
|
||||
}
|
||||
|
||||
public boolean get_real_time(){
|
||||
return real_time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(String s){
|
||||
com.send(s);
|
||||
}
|
||||
}
|
||||
|
||||
class SelectionTool extends ObjectConstructor{
|
||||
private ZTextFieldAndLabel targetslist;
|
||||
private ClientNetworkTools cnt = null;
|
||||
|
||||
public SelectionTool(ClientNetworkTools cnt, ZTextFieldAndLabel targetslist){
|
||||
this.targetslist = targetslist;
|
||||
this.cnt = cnt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e, ZirkelCanvas zc){
|
||||
final ConstructionObject o = zc.selectObject(e.getX(), e.getY());
|
||||
if(o==null){
|
||||
return;
|
||||
}
|
||||
if((cnt.get_accepted_object("point") && o instanceof PointObject)
|
||||
|| (cnt.get_accepted_object("line") && o instanceof PrimitiveLineObject)
|
||||
|| (cnt.get_accepted_object("circle") && o instanceof PrimitiveCircleObject)
|
||||
|| (cnt.get_accepted_object("function") && o instanceof FunctionObject)){
|
||||
if(o.selected()){
|
||||
o.setSelected(false);
|
||||
targetslist.setText(targetslist.getText().replaceAll(o.getName()+";", ""));
|
||||
} else {
|
||||
o.setSelected(true);
|
||||
targetslist.setText(targetslist.getText()+o.getName()+";");
|
||||
}
|
||||
zc.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent e, final ZirkelCanvas zc, final boolean simple) {
|
||||
Enumeration en = zc.getConstruction().elements();
|
||||
MyVector V = new MyVector();
|
||||
while(en.hasMoreElements()){
|
||||
ConstructionObject o = (ConstructionObject) en.nextElement();
|
||||
if(o.nearto(e.getX(), e.getY(), zc)){
|
||||
if((cnt.get_accepted_object("point") && o instanceof PointObject)
|
||||
|| (cnt.get_accepted_object("line") && o instanceof PrimitiveLineObject)
|
||||
|| (cnt.get_accepted_object("circle") && o instanceof PrimitiveCircleObject)
|
||||
|| (cnt.get_accepted_object("function") && o instanceof FunctionObject)){
|
||||
V.addElement(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
zc.indicate(V);
|
||||
}
|
||||
}
|
66
pm/Client/Communication.java
Normal file
66
pm/Client/Communication.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package pm.Client;
|
||||
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.JZirkelCanvas;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PM
|
||||
*/
|
||||
public class Communication implements Runnable {
|
||||
|
||||
private Socket socket = null;
|
||||
private PrintWriter out = null;
|
||||
private BufferedReader in = null;
|
||||
private ClientNetworkTools cnt = null;
|
||||
|
||||
public Communication (Socket socket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
cnt = new ClientNetworkTools(this);
|
||||
ZirkelCanvas zc = JZirkelCanvas.getCurrentZC();
|
||||
zc.add(cnt);
|
||||
zc.set_cnt(cnt);
|
||||
zc.repaint();
|
||||
zc.init_cnt();
|
||||
PaletteManager.setSelected_with_clic("move", true);
|
||||
|
||||
out = new PrintWriter(socket.getOutputStream());
|
||||
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
|
||||
new Thread(new Reception(in, cnt, this)).start();
|
||||
} catch (IOException e) {
|
||||
cnt.doClose();
|
||||
close();
|
||||
System.out.println("Erreur de communication (com_client)");
|
||||
}
|
||||
}
|
||||
|
||||
public void send(String msg){
|
||||
out.println(msg+"END_MESSAGE");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
public void close(){
|
||||
send("<End>\n");
|
||||
out.close();
|
||||
try {
|
||||
//socket.close();
|
||||
in.close();
|
||||
} catch (IOException ex) {}
|
||||
}
|
||||
}
|
162
pm/Client/ConnectionControlPanel.java
Normal file
162
pm/Client/ConnectionControlPanel.java
Normal file
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package pm.Client;
|
||||
|
||||
import eric.GUI.ZDialog.ZButton;
|
||||
import eric.GUI.ZDialog.ZDialog;
|
||||
import eric.GUI.ZDialog.ZTextFieldAndLabel;
|
||||
import eric.GUI.ZDialog.ZTools;
|
||||
import eric.GUI.palette.PaletteManager;
|
||||
import eric.JZirkelCanvas;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.KeyEvent;
|
||||
import rene.gui.Global;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PM
|
||||
*/
|
||||
public class ConnectionControlPanel extends ZDialog {
|
||||
|
||||
private ZTextFieldAndLabel name, ip, port;
|
||||
private ZButton connect;
|
||||
private Thread t;
|
||||
private Color color = Color.RED;
|
||||
private int PORT = 2357;
|
||||
|
||||
public ConnectionControlPanel() {
|
||||
super(Global.Loc("network.client.title"), 3, 90, 220, 135, true, true);
|
||||
BWIDTH = 100;
|
||||
LWIDTH = 70;
|
||||
addContent();
|
||||
}
|
||||
|
||||
private void addContent() {
|
||||
name = new ZTextFieldAndLabel(Global.Loc("network.client.Name"), Global.getParameter("network.name", Global.Loc("network.client.name")), LWIDTH, CHEIGHT){
|
||||
@Override
|
||||
public void focusGained() {
|
||||
if(this.getText().equals(Global.Loc("network.client.name"))){
|
||||
this.setText("");
|
||||
this.setForeground(ZTools.C_TextField);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(){
|
||||
if(this.getText().equals("")){
|
||||
this.setText(Global.Loc("network.client.name"));
|
||||
this.setForeground(ZTools.C_TextField_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionKey(KeyEvent k){
|
||||
if(k.getKeyCode()==KeyEvent.VK_ENTER){
|
||||
connect.action();
|
||||
} else {
|
||||
this.setForeground(ZTools.C_TextField);
|
||||
}
|
||||
}
|
||||
};
|
||||
name.setForeground(name.getText().equals(Global.Loc("network.client.name"))?ZTools.C_TextField_OFF:ZTools.C_TextField);
|
||||
|
||||
ip = new ZTextFieldAndLabel(Global.Loc("network.client.ip"), Global.getParameter("network.ip", "ip (xxx.xxx.xxx.xxx)"), LWIDTH, CHEIGHT){
|
||||
@Override
|
||||
public void focusGained(){
|
||||
if(this.getText().equals("ip (xxx.xxx.xxx.xxx)")){
|
||||
this.setText("");
|
||||
}
|
||||
this.setForeground(ZTools.C_TextField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(){
|
||||
if(this.getText().equals("")){
|
||||
this.setText("ip (xxx.xxx.xxx.xxx)");
|
||||
this.setForeground(ZTools.C_TextField_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionKey(KeyEvent k){
|
||||
if(k.getKeyCode()==KeyEvent.VK_ENTER){
|
||||
connect.action();
|
||||
} else {
|
||||
this.setForeground(ZTools.C_TextField);
|
||||
}
|
||||
}
|
||||
};
|
||||
ip.setForeground(ip.getText().equals("ip (xxx.xxx.xxx.xxx)")?ZTools.C_TextField_OFF:ZTools.C_TextField);
|
||||
|
||||
port = new ZTextFieldAndLabel(Global.Loc("network.client.port"), Integer.toString(PORT), LWIDTH, CHEIGHT){
|
||||
@Override
|
||||
public void focusGained(){
|
||||
//this.setForeground(ZTools.C_TextField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(){
|
||||
}
|
||||
};
|
||||
port.setEditable(false);
|
||||
port.setForeground(ZTools.C_TextField_OFF);
|
||||
|
||||
connect = new ZButton(Global.Loc("network.client.connect")){
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
Global.setParameter("network.name", name.getText());
|
||||
if(can_connect(name, ip)){
|
||||
Global.setParameter("network.ip", ip.getText());
|
||||
t = new Thread(new Client(name.getText(), ip.getText(), PORT, (ConnectionControlPanel) this.getParent()));
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.add(name);
|
||||
this.add(ip);
|
||||
this.add(port);
|
||||
this.add(connect);
|
||||
}
|
||||
|
||||
private boolean can_connect(ZTextFieldAndLabel name, ZTextFieldAndLabel ip){
|
||||
boolean b = true;
|
||||
String NAME = name.getText(), IP = ip.getText();
|
||||
|
||||
if(NAME.equals("") || NAME.equals(Global.Loc("network.client.name"))){
|
||||
name.setText(Global.Loc("network.client.name"));
|
||||
name.setForeground(color);
|
||||
b = false;
|
||||
}
|
||||
if(IP.equals("")){
|
||||
ip.setText("ip (xxx.xxx.xxx.xxx)");
|
||||
ip.setForeground(color);
|
||||
b = false;
|
||||
}
|
||||
if(!IP.matches("^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$")){
|
||||
ip.setForeground(color);
|
||||
b = false;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixComponents(){
|
||||
name.setBounds(MARGINW, MARGINTOP1, D_WIDTH-2*MARGINW, CHEIGHT);
|
||||
ip.setBounds(MARGINW, MARGINTOP2, D_WIDTH-2*MARGINW, CHEIGHT);
|
||||
port.setBounds(MARGINW, MARGINTOP3, D_WIDTH-2*MARGINW, CHEIGHT);
|
||||
connect.setBounds(D_WIDTH/2-BWIDTH/2, MARGINTOP4, BWIDTH, CHEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doClose() {
|
||||
JZirkelCanvas.getCurrentZC().remove(this);
|
||||
JZirkelCanvas.getCurrentZC().repaint();
|
||||
PaletteManager.ClicOn("move");
|
||||
}
|
||||
|
||||
}
|
43
pm/Client/Connexion.java
Normal file
43
pm/Client/Connexion.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package pm.Client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PM
|
||||
*/
|
||||
public class Connexion implements Runnable {
|
||||
|
||||
private Socket socket = null;
|
||||
private PrintWriter out = null;
|
||||
private String login = null;
|
||||
|
||||
public Connexion(Socket socket, String login){
|
||||
this.socket = socket;
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
out = new PrintWriter(socket.getOutputStream());
|
||||
|
||||
out.println(login);
|
||||
out.flush();
|
||||
|
||||
new Thread(new Communication(socket)).start();
|
||||
} catch (IOException e) {
|
||||
out.close();
|
||||
try {
|
||||
socket.close();
|
||||
} catch (Exception ee){}
|
||||
System.out.println("Erreur de connexion (Connexion)");
|
||||
}
|
||||
}
|
||||
}
|
91
pm/Client/Reception.java
Normal file
91
pm/Client/Reception.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package pm.Client;
|
||||
|
||||
import eric.FileTools;
|
||||
import eric.JZirkelCanvas;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import rene.zirkel.ZirkelCanvas;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PM
|
||||
*/
|
||||
public class Reception implements Runnable {
|
||||
|
||||
private BufferedReader in = null;
|
||||
private String message = null;
|
||||
private ClientNetworkTools cnt = null;
|
||||
private Communication Com = null;
|
||||
private ZirkelCanvas ZC;
|
||||
|
||||
public Reception(BufferedReader in, ClientNetworkTools cnt, Communication Com){
|
||||
this.in = in;
|
||||
this.cnt = cnt;
|
||||
this.Com = Com;
|
||||
ZC = JZirkelCanvas.getCurrentZC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while(true){
|
||||
String src = "";
|
||||
/*
|
||||
while((message = in.readLine())!=null){
|
||||
src += message+"\n";
|
||||
}
|
||||
*
|
||||
*/
|
||||
message = in.readLine();
|
||||
while(message!=null && !message.equals("END_MESSAGE")) {
|
||||
src += message+"\n";
|
||||
message = in.readLine();
|
||||
}
|
||||
//System.out.println("src =\n"+src);
|
||||
if(src.startsWith("<Accepted objects>")) {
|
||||
String objs[] = src.split("\n");
|
||||
String obj[];
|
||||
for(int i = 1; i<objs.length-1; i++) {
|
||||
obj = objs[i].split("=");
|
||||
cnt.set_accepted_object(obj[0], Boolean.parseBoolean(obj[1]));
|
||||
}
|
||||
} else if(src.startsWith("<Real time>")) {
|
||||
if(src.endsWith("true\n"+"")) {
|
||||
cnt.set_real_time(true);
|
||||
try {
|
||||
Com.send(FileTools.getCurrentFileSource());
|
||||
} catch(Exception e){
|
||||
System.err.println("Erreur d'envoi (Client/Reception)");
|
||||
}
|
||||
} else {
|
||||
cnt.set_real_time(false);
|
||||
}
|
||||
} else if(src.startsWith("<End>")) {
|
||||
cnt.doClose();
|
||||
} else if(src.contains("<CaR>")) { //receiving the whole figure
|
||||
try {
|
||||
//tab_main_panel.getActivePanel().getZC().setFileSource(src);
|
||||
ZC.setFileSource(src);
|
||||
} catch (Exception ex){}
|
||||
} else if(src.startsWith("<To")) { //add, update, delete, change name
|
||||
ZC.update_local(src);
|
||||
} else if(src.startsWith("<Collaboration>")) {
|
||||
cnt.set_real_time(src.endsWith("true\n"+""));
|
||||
} else {
|
||||
System.err.println("Not implemented yet");
|
||||
System.out.println(src);
|
||||
System.out.println("-------------------");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
cnt.doClose();
|
||||
System.err.println("Serveur OffLine");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue