OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 132 Rev 180
Line 144... Line 144...
144
            return lab;
144
            return lab;
145
        }
145
        }
146
    }
146
    }
147
 
147
 
148
    /**
148
    /**
149
     * Ajout un composant sur une ligne Si comp est null, un titre est créé.
149
     * Ajout un composant sur une ligne.
150
     * 
150
     * 
151
     * @param desc le label du champ.
151
     * @param desc le label du champ, <code>null</code> if <code>comp</<code> should use its area.
152
     * @param comp le composant graphique d'edition.
152
     * @param comp le composant graphique d'edition.
153
     * @param w la largeur, entre 1 et la largeur de ce layout, ou 0 pour toute la largeur.
153
     * @param w la largeur, entre 1 et la largeur de ce layout, ou 0 pour toute la largeur.
154
     * @return the created label.
154
     * @return the created label.
155
     * @throws NullPointerException if comp is <code>null</code>.
155
     * @throws NullPointerException if comp is <code>null</code>.
156
     * @throws IllegalArgumentException if w is less than 1.
156
     * @throws IllegalArgumentException if w is less than 1.
157
     */
157
     */
158
    public JLabel add(String desc, Component comp, int w) {
158
    public JLabel add(String desc, Component comp, int w) {
159
        w = this.checkArgs(comp, w);
159
        w = this.checkArgs(comp, w);
160
 
160
 
161
        final int realWidth = this.getRealFieldWidth(w);
161
        int realWidth = this.getRealFieldWidth(w);
-
 
162
        final JLabel lab;
-
 
163
        final int fieldX;
-
 
164
        if (desc == null) {
-
 
165
            lab = null;
-
 
166
            fieldX = this.getLabelX();
-
 
167
            realWidth += this.getFieldX() - fieldX;
-
 
168
        } else {
-
 
169
            lab = new JLabel(desc);
162
        // Guillaume : right alignment like the Mac
170
            // Guillaume : right alignment like the Mac
163
        final JLabel lab = new JLabel(desc);
-
 
164
        this.co.add(lab, this.constraints.xy(this.getLabelX(), this.getY(), CellConstraints.RIGHT, this.getRowAlign()));
171
            this.co.add(lab, this.constraints.xy(this.getLabelX(), this.getY(), CellConstraints.RIGHT, this.getRowAlign()));
-
 
172
            fieldX = this.getFieldX();
-
 
173
        }
165
        this.co.add(comp, this.constraints.xyw(this.getFieldX(), this.getY(), realWidth, CellConstraints.DEFAULT, this.getRowAlign()));
174
        this.co.add(comp, this.constraints.xyw(fieldX, this.getY(), realWidth, CellConstraints.DEFAULT, this.getRowAlign()));
166
        this.x += w;
175
        this.x += w;
167
        return lab;
176
        return lab;
168
    }
177
    }
169
 
178
 
170
    // assure that comp & w are valid, and do a newLine if necessary
179
    // assure that comp & w are valid, and do a newLine if necessary