OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 162 Rev 181
Line 34... Line 34...
34
 
34
 
35
    public void createElement(final Extension ext) {
35
    public void createElement(final Extension ext) {
36
        // Create elements
36
        // Create elements
37
        ComptaPropsConfiguration conf = ComptaPropsConfiguration.getInstanceCompta();
37
        ComptaPropsConfiguration conf = ComptaPropsConfiguration.getInstanceCompta();
38
        DBRoot root = conf.getRootSociete();
38
        DBRoot root = conf.getRootSociete();
39
        if (conf.getDirectory().getElement(name) == null) {
39
        if (conf.getDirectory().getElement(this.name) == null) {
40
            final SQLTable table = root.getTable(name);
40
            final SQLTable table = root.getTable(this.name);
41
            final SQLElement e = new SQLElement("ext." + name, "ext." + name, table) {
41
            final SQLElement e = new SQLElement("ext." + this.name, "ext." + this.name, table) {
42
 
42
 
43
                @Override
43
                @Override
44
                protected List<String> getListFields() {
44
                protected List<String> getListFields() {
45
                    return new ArrayList<String>(0);
45
                    return new ArrayList<String>(0);
46
                }
46
                }
Line 58... Line 58...
58
                    if (matchCodeNom == 2) {
58
                    if (matchCodeNom == 2) {
59
                        l.add("CODE");
59
                        l.add("CODE");
60
                        l.add("NOM");
60
                        l.add("NOM");
61
                    } else {
61
                    } else {
62
                        ListDescriptor listDesc = null;
62
                        ListDescriptor listDesc = null;
-
 
63
                        l.clear();
63
                        for (ListDescriptor listDescriptor : ext.getCreateListList()) {
64
                        for (ListDescriptor listDescriptor : ext.getCreateListList()) {
64
                            if (listDescriptor.getMainTable().equals(getTable().getName())) {
65
                            if (listDescriptor.getMainTable().equals(getTable().getName())) {
65
                                listDesc = listDescriptor;
66
                                listDesc = listDescriptor;
66
                                break;
67
                                break;
67
                            }
68
                            }
68
                        }
69
                        }
-
 
70
                        if (listDesc != null) {
69
                        for (ColumnDescriptor string : listDesc.getColumns()) {
71
                            for (ColumnDescriptor string : listDesc.getColumns()) {
70
                            if (!string.getFieldsPaths().contains(".")) {
72
                                if (!string.getFieldsPaths().contains(".")) {
71
                                l.add(string.getFieldsPaths());
73
                                    l.add(string.getFieldsPaths());
72
                                break;
74
                                    break;
73
                            }
75
                                }
74
                        }
76
                            }
75
                    }
77
                        }
-
 
78
                        if (l.isEmpty()) {
-
 
79
                            if (!getTable().getContentFields().isEmpty()) {
-
 
80
                                l.add(new ArrayList<>(getTable().getContentFields()).get(0).getName());
-
 
81
                            }
-
 
82
                        }
-
 
83
                    }
76
                    return l;
84
                    return l;
77
                }
85
                }
78
 
86
 
79
                @Override
87
                @Override
80
                protected SQLTableModelSourceOnline instantiateTableSourceOnline(ListSQLRequest req) {
88
                protected SQLTableModelSourceOnline instantiateTableSourceOnline(ListSQLRequest req) {
Line 99... Line 107...
99
                    for (final ComponentDescritor cDescriptor : ext.getCreateComponentList()) {
107
                    for (final ComponentDescritor cDescriptor : ext.getCreateComponentList()) {
100
                        if (cDescriptor.getTable().equals(table.getTable().getName())) {
108
                        if (cDescriptor.getTable().equals(table.getTable().getName())) {
101
                            return new ExtensionGroupSQLComponent(this, cDescriptor.getGroup());
109
                            return new ExtensionGroupSQLComponent(this, cDescriptor.getGroup());
102
                        }
110
                        }
103
                    }
111
                    }
104
                    JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + name);
112
                    JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + TableDescritor.this.name);
105
                    return null;
113
                    return null;
106
                }
114
                }
107
            };
115
            };
108
            conf.getDirectory().addSQLElement(e);
116
            conf.getDirectory().addSQLElement(e);
109
            Log.get().info("Autocreate element for table: " + table.getName());
117
            Log.get().info("Autocreate element for table: " + table.getName());
110
        }
118
        }
111
    }
119
    }
112
 
120
 
113
    public String getName() {
121
    public String getName() {
114
        return name;
122
        return this.name;
115
    }
123
    }
116
 
124
 
117
    public void setName(String name) {
125
    public void setName(String name) {
118
        this.name = name;
126
        this.name = name;
119
    }
127
    }
120
 
128
 
121
    public List<FieldDescriptor> getFields() {
129
    public List<FieldDescriptor> getFields() {
122
        return fields;
130
        return this.fields;
123
    }
131
    }
124
 
132
 
125
    public void add(FieldDescriptor f) {
133
    public void add(FieldDescriptor f) {
126
        fields.add(f);
134
        this.fields.add(f);
127
 
135
 
128
    }
136
    }
129
 
137
 
130
    public void remove(FieldDescriptor field) {
138
    public void remove(FieldDescriptor field) {
131
        fields.remove(field);
139
        this.fields.remove(field);
132
 
140
 
133
    }
141
    }
134
 
142
 
135
    @Override
143
    @Override
136
    public String toString() {
144
    public String toString() {
137
        return name;
145
        return this.name;
138
    }
146
    }
139
 
147
 
140
    public void sortFields() {
148
    public void sortFields() {
141
        Collections.sort(this.fields, new Comparator<FieldDescriptor>() {
149
        Collections.sort(this.fields, new Comparator<FieldDescriptor>() {
142
 
150