OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 198... Line 198...
198
        this.id = id;
198
        this.id = id;
199
        this.UUID = getNextUUID();// java.util.UUID.randomUUID().toString();
199
        this.UUID = getNextUUID();// java.util.UUID.randomUUID().toString();
200
    }
200
    }
201
 
201
 
202
    private static long count = 0;
202
    private static long count = 0;
203
    private static Integer counterLock = new Integer(123456);
203
    private static Object counterLock = new Object();
204
 
204
 
205
    private String getNextUUID() {
205
    private String getNextUUID() {
206
        String result;
206
        String result;
207
        synchronized (counterLock) {
207
        synchronized (counterLock) {
208
            count++;
208
            count++;
Line 534... Line 534...
534
    public String getId() {
534
    public String getId() {
535
        return this.id;
535
        return this.id;
536
    }
536
    }
537
 
537
 
538
    public void setId(final String id) {
538
    public void setId(final String id) {
-
 
539
        if (id == null) {
-
 
540
            throw new IllegalArgumentException("id cannot be null");
-
 
541
        }
539
        this.id = id;
542
        this.id = id;
-
 
543
 
540
    }
544
    }
541
 
545
 
542
    public String getUUID() {
546
    public String getUUID() {
543
        return this.UUID;
547
        return this.UUID;
544
    }
548
    }
Line 807... Line 811...
807
 
811
 
808
    protected void copy(final LightUIElement element) {
812
    protected void copy(final LightUIElement element) {
809
        if (element == null) {
813
        if (element == null) {
810
            throw new IllegalArgumentException("Try to copy attributes of null element in " + this.getId());
814
            throw new IllegalArgumentException("Try to copy attributes of null element in " + this.getId());
811
        }
815
        }
-
 
816
        System.err.println("LightUIElement.copy() " + element);
-
 
817
        this.UUID = getNextUUID();
-
 
818
        this.id = element.getId();
812
        this.fontSize = element.fontSize;
819
        this.fontSize = element.fontSize;
813
        this.gridHeight = element.gridHeight;
820
        this.gridHeight = element.gridHeight;
814
        this.gridWidth = element.gridWidth;
821
        this.gridWidth = element.gridWidth;
815
        this.horizontalAlignment = element.horizontalAlignment;
822
        this.horizontalAlignment = element.horizontalAlignment;
816
        this.verticalAlignment = element.verticalAlignment;
823
        this.verticalAlignment = element.verticalAlignment;
Line 864... Line 871...
864
        this.foreColor = element.foreColor;
871
        this.foreColor = element.foreColor;
865
    }
872
    }
866
 
873
 
867
    @Override
874
    @Override
868
    public String toString() {
875
    public String toString() {
869
        if (!destroyed) {
876
        if (!this.destroyed) {
870
            return super.toString() + " " + this.id;
877
            return super.toString() + " " + this.id;
871
        } else {
878
        } else {
872
            return super.toString() + " " + this.id + " DESTROYED";
879
            return super.toString() + " " + this.id + " DESTROYED";
873
        }
880
        }
874
    }
881
    }
Line 1010... Line 1017...
1010
            result.put("label", this.label);
1017
            result.put("label", this.label);
1011
        }
1018
        }
1012
        if (this.toolTip != null) {
1019
        if (this.toolTip != null) {
1013
            result.put("tool-tip", this.toolTip);
1020
            result.put("tool-tip", this.toolTip);
1014
        }
1021
        }
-
 
1022
        if (this.UUID == null) {
-
 
1023
            throw new IllegalStateException("null UUID, id: " + this.id);
-
 
1024
        }
1015
        result.put("uuid", this.UUID);
1025
        result.put("uuid", this.UUID);
1016
        if (this.value != null) {
1026
        if (this.value != null) {
1017
            result.put("value", this.value);
1027
            result.put("value", this.value);
1018
        }
1028
        }
1019
        if (this.valuePrecision != null) {
1029
        if (this.valuePrecision != null) {
Line 1043... Line 1053...
1043
 
1053
 
1044
    @Override
1054
    @Override
1045
    public void fromJSON(final JSONObject json) {
1055
    public void fromJSON(final JSONObject json) {
1046
        this.id = JSONConverter.getParameterFromJSON(json, "id", String.class);
1056
        this.id = JSONConverter.getParameterFromJSON(json, "id", String.class);
1047
        this.UUID = JSONConverter.getParameterFromJSON(json, "uuid", String.class);
1057
        this.UUID = JSONConverter.getParameterFromJSON(json, "uuid", String.class);
-
 
1058
        if (this.UUID == null) {
-
 
1059
            throw new IllegalArgumentException("null UUID, id : " + this.id);
-
 
1060
        }
1048
        this.displayPrecision = JSONConverter.getParameterFromJSON(json, "display-precision", String.class);
1061
        this.displayPrecision = JSONConverter.getParameterFromJSON(json, "display-precision", String.class);
1049
        this.icon = JSONConverter.getParameterFromJSON(json, "icon", String.class);
1062
        this.icon = JSONConverter.getParameterFromJSON(json, "icon", String.class);
1050
        this.label = JSONConverter.getParameterFromJSON(json, "label", String.class);
1063
        this.label = JSONConverter.getParameterFromJSON(json, "label", String.class);
1051
 
1064
 
1052
        this.toolTip = JSONConverter.getParameterFromJSON(json, "tool-tip", String.class);
1065
        this.toolTip = JSONConverter.getParameterFromJSON(json, "tool-tip", String.class);
Line 1107... Line 1120...
1107
        this.parent = null;
1120
        this.parent = null;
1108
        this.destroyed = true;
1121
        this.destroyed = true;
1109
    }
1122
    }
1110
 
1123
 
1111
    public boolean isDestroyed() {
1124
    public boolean isDestroyed() {
1112
        return destroyed;
1125
        return this.destroyed;
1113
    }
1126
    }
1114
 
1127
 
1115
    @Override
1128
    @Override
1116
    public void writeExternal(ObjectOutput out) throws IOException {
1129
    public void writeExternal(ObjectOutput out) throws IOException {
1117
        out.writeInt(this.type);
1130
        out.writeInt(this.type);
1118
        if (this.id == null) {
1131
        if (this.id == null) {
1119
            throw new IllegalStateException("null id");
1132
            throw new IllegalStateException("null id");
1120
        }
1133
        }
1121
        out.writeUTF(this.id);
1134
        out.writeUTF(this.id);
1122
        if (this.UUID == null) {
1135
        if (this.UUID == null) {
1123
            throw new IllegalStateException("UUID");
1136
            throw new IllegalStateException("null UUID, id : " + this.id);
1124
        }
1137
        }
1125
        out.writeUTF(this.UUID);
1138
        out.writeUTF(this.UUID);
1126
 
1139
 
1127
        writeIfNotNull(out, this.label);
1140
        writeIfNotNull(out, this.label);
1128
        writeIfNotNull(out, this.value);
1141
        writeIfNotNull(out, this.value);
Line 1221... Line 1234...
1221
    @Override
1234
    @Override
1222
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
1235
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
1223
        this.type = in.readInt();
1236
        this.type = in.readInt();
1224
        this.id = in.readUTF();
1237
        this.id = in.readUTF();
1225
        this.UUID = in.readUTF();
1238
        this.UUID = in.readUTF();
-
 
1239
        if (this.UUID == null) {
-
 
1240
            throw new IllegalStateException("null UUID, id : " + this.id);
-
 
1241
        }
1226
        if (in.readBoolean()) {
1242
        if (in.readBoolean()) {
1227
            this.label = in.readUTF();
1243
            this.label = in.readUTF();
1228
        }
1244
        }
1229
        if (in.readBoolean()) {
1245
        if (in.readBoolean()) {
1230
            this.value = in.readUTF();
1246
            this.value = in.readUTF();