Revision 2035

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/TitledSeparator.java
1
package org.gvsig.tools.swing.impl;
2

  
3
import java.awt.Color;
4
import java.awt.Component;
5
import java.awt.Dimension;
6
import java.awt.Graphics;
7
import java.awt.Graphics2D;
8
import java.awt.LinearGradientPaint;
9
import java.awt.Paint;
10
import java.awt.geom.Point2D;
11
import javax.swing.BorderFactory;
12
import javax.swing.Icon;
13
import javax.swing.JLabel;
14
import javax.swing.UIManager;
15

  
16
/*
17
 * Based on portions of code from java.awt.geom.TitledSeparator of the
18
 * aterai/java-swing-tips project (Copyright (c) 2015 TERAI Atsuhiro)
19
 * https://github.com/aterai/java-swing-tips/tree/master/TitledSeparator
20
 */
21
public class TitledSeparator extends JLabel {
22

  
23
    private Color color;
24
    private final String title;
25
    private final Color target;
26
    private final int height;
27
    private final int titlePosition;
28
    private final int titleJustification;
29

  
30
    public TitledSeparator(String title, int height, int titlePosition, int titleJustification) {
31
        this(title, null, height, titlePosition, titleJustification);
32
    }
33

  
34
    public TitledSeparator(
35
            String _title, Color _target, int _height, int _titlePosition, int _titleJustification) {
36
        super();
37
        this.title = _title;
38
        this.target = _target;
39
        this.height = _height;
40
        this.titlePosition = _titlePosition;
41
        this.titleJustification = _titleJustification;
42
        Icon icon = new Icon() {
43
            private int width = -1;
44
            private Paint painter1, painter2;
45

  
46
            @Override
47
            public void paintIcon(Component c, Graphics g, int x, int y) {
48
                int w = c.getWidth();
49
                if (w != width || painter1 == null || painter2 == null || color == null) {
50
                    width = w;
51
                    Point2D start = new Point2D.Float(0f, 0f);
52
                    Point2D end = new Point2D.Float((float) width, 0f);
53
                    float[] dist = {0.0f, 1.0f};
54
                    color = getBackground();
55
                    color = color == null ? UIManager.getColor("Panel.background") : color;
56
                    Color tc = target == null ? color : target;
57
                    painter1 = new LinearGradientPaint(
58
                            start, end, dist, new Color[]{tc.darker(), color});
59
                    painter2 = new LinearGradientPaint(
60
                            start, end, dist, new Color[]{tc.brighter(), color});
61
                }
62
                int h = getIconHeight() / 2;
63
                Graphics2D g2 = (Graphics2D) g.create();
64
                g2.setPaint(painter1);
65
                g2.fillRect(x, y, width, getIconHeight());
66
                g2.setPaint(painter2);
67
                g2.fillRect(x, y + h, width, getIconHeight() - h);
68
                g2.dispose();
69
            }
70

  
71
            @Override
72
            public int getIconWidth() {
73
                return 200;
74
            } //dummy width
75

  
76
            @Override
77
            public int getIconHeight() {
78
                return height;
79
            }
80
        };
81
        this.setBorder(BorderFactory.createTitledBorder(
82
                BorderFactory.createMatteBorder(height, 0, 0, 0, icon), title,
83
                titleJustification, titlePosition));
84
    }
85

  
86
    @Override
87
    public Dimension getMaximumSize() {
88
        Dimension d = super.getPreferredSize();
89
        d.width = Short.MAX_VALUE;
90
        return d;
91
    }
92

  
93
    @Override
94
    public void updateUI() {
95
        super.updateUI();
96
        color = null;
97
    }
98
}
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DefaultToolsSwingManager.java
31 31
import javax.swing.JTabbedPane;
32 32
import javax.swing.JTextField;
33 33
import javax.swing.JViewport;
34
import javax.swing.border.TitledBorder;
34 35
import javax.swing.table.TableModel;
35 36
import javax.swing.text.DefaultEditorKit;
36 37
import javax.swing.text.JTextComponent;
......
582 583
        return model;
583 584
    }
584 585

  
586
    @Override
587
    public JLabel createTitledSeparator(String title, int height, int titlePosition, int titleJustification) {
588
        TitledSeparator c = new TitledSeparator(title, height, titlePosition, titleJustification);
589
        return c;
590
    }
591

  
592
    @Override
593
    public JLabel createTitledSeparator(String title) {
594
        TitledSeparator c = new TitledSeparator(
595
                title, 
596
                2, 
597
                TitledBorder.DEFAULT_POSITION, 
598
                TitledBorder.DEFAULT_JUSTIFICATION
599
        );
600
        return c;
601
    }
585 602
}
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/ToolsSwingManager.java
247 247
    public HistoryController createHistoryController(History history, JButton button);
248 248

  
249 249
    public FilteredTableModel createFilteredTableModel(TableModel model, int filterColumn);
250
    
251
    public JLabel createTitledSeparator(String title, int height, int titlePosition, int titleJustification);
252

  
253
    public JLabel createTitledSeparator(String title);
250 254
}
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynform/AbstractJDynForm.java
393 393
        }
394 394
    }
395 395

  
396
    protected List<Action> getCustomFields(DataType dataType) {
396
    protected List<Action> getCustomActionsForDataType(DataType dataType) {
397 397
        return (List<Action>) customActions.get(dataType.getName());
398 398
    }
399 399

  
400 400
    @Override
401 401
    public void addActionToPopupMenu(DataType tipo, String name, Action action) {
402
        List<Action> acts = this.getCustomFields(tipo);
402
        List<Action> acts = this.getCustomActionsForDataType(tipo);
403 403
        action.putValue(Action.NAME, name);
404 404
        if (acts == null) {
405 405
            List<Action> aux = new ArrayList<>();
......
412 412

  
413 413
    @Override
414 414
    public void addSeparatorToPopupMenu(DataType tipo) {
415
        List<Action> acts = this.getCustomFields(tipo);
415
        List<Action> acts = this.getCustomActionsForDataType(tipo);
416 416
        if (acts == null) {
417 417
            List<Action> aux = new ArrayList<>();
418 418
            aux.add(null);
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/AbstractJDynFormField.java
161 161
    }
162 162

  
163 163
    @Override
164
    public String getSeparatorTitleToUseBefore() {
165
        String separatorTitle = this.getTagValueAsString(
166
                DynFormSPIManager.TAG_DYNFORM_SEPARATOR, 
167
                null
168
        );
169
        return separatorTitle;
170
    }
171
    
172
    @Override
173
    public boolean useEmptyLabel() {
174
        boolean useEmpty = getTagValueAsBoolean(
175
                DynFormSPIManager.TAG_DYNFORM_LABEL_EMPTY, 
176
                false
177
        );
178
        return useEmpty;
179
    }
180
    
181
    @Override
164 182
    public JComponent getJLabel() {
165 183
        if (this.jlabel == null) {
166 184
            this.jlabel = this.getComponentsFactory().getJLabel(definition, null);
167 185
            if( this.jlabel==null ) {
168 186
                this.jlabel = new JLabel();
169 187
            }
170
            if (!getTagValueAsBoolean(DynFormSPIManager.TAG_DYNFORM_LABEL_EMPTY, false)) {
188
            if (!this.useEmptyLabel() ) {
171 189
                this.jlabel.setText(this.getLabel());
172 190
            }
173 191
            this.jlabel.setLabelFor(this.contents);
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.impl/src/main/java/org/gvsig/tools/dynform/impl/DefaultJDynForm.java
22 22
 */
23 23
package org.gvsig.tools.dynform.impl;
24 24

  
25
import java.awt.Component;
25 26
import org.gvsig.tools.dynform.spi.dynform.AbstractJDynForm;
26 27
import java.util.ArrayList;
27 28
import java.util.HashMap;
......
49 50
import org.gvsig.tools.dynobject.DynObject;
50 51
import org.gvsig.tools.service.ServiceException;
51 52

  
52
import com.jgoodies.forms.builder.DefaultFormBuilder;
53
import com.jgoodies.forms.layout.CellConstraints;
54
import com.jgoodies.forms.layout.FormLayout;
55
import com.jgoodies.forms.layout.RowSpec;
53
import java.awt.GridBagConstraints;
54
import java.awt.GridBagLayout;
55
import java.awt.Insets;
56 56
import java.util.Collection;
57
import javax.swing.JLabel;
58
import javax.swing.JPanel;
57 59
import org.gvsig.tools.dynform.spi.DynFormSPIManager;
58 60
import org.gvsig.tools.dynform.spi.DynFormSPIManager.ComponentsFactory;
59
import static org.gvsig.tools.dynform.spi.DynFormSPIManager.TAG_DYNFORM_SEPARATOR;
60 61
import static org.gvsig.tools.dynform.spi.DynFormSPIManager.USERCODE_FORM_CLEAR;
61 62
import static org.gvsig.tools.dynform.spi.DynFormSPIManager.USERCODE_FORM_ISMODIFIED;
62 63
import static org.gvsig.tools.dynform.spi.DynFormSPIManager.USERCODE_FORM_ISREADONLY;
......
69 70
import org.gvsig.tools.dynform.spi.dynform.JDynFormFactory;
70 71
import org.gvsig.tools.dynform.spi.dynformfield.JDynFormFieldFactory;
71 72
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField;
72
import org.gvsig.tools.dynobject.Tags;
73 73
import org.gvsig.tools.i18n.I18nManager;
74
import org.gvsig.tools.swing.api.ToolsSwingLocator;
75
import org.gvsig.tools.swing.api.ToolsSwingManager;
74 76

  
75 77
@SuppressWarnings("UseSpecificCatch")
76 78
public class DefaultJDynForm extends AbstractJDynForm implements JDynFormFieldListener {
......
115 117
    }
116 118

  
117 119
    private JComponent getFieldsContainerPlain() throws ServiceException {
118
        FormLayout layout = new FormLayout(
119
                "left:pref,  8px,  fill:80dlu:grow", "pref");
120

  
121
        DefaultFormBuilder builder = new DefaultFormBuilder(layout);
122
        builder.defaultRowSpec(new RowSpec(
123
                RowSpec.TOP,
124
                builder.getLayout().getRowSpec(1).getSize(),
125
                builder.getLayout().getRowSpec(1).getResizeWeight()));
126

  
127
        List fields = this.getDefinition().getDefinitions();
128
        Iterator it = fields.iterator();
129
        while (it.hasNext()) {
130
            DynFormFieldDefinition fieldDefinition = (DynFormFieldDefinition) it.next();
120
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
121
        GridBagConstraints c = new GridBagConstraints();
122
        c.insets = new Insets(2, 2, 2, 2);
123
        c.anchor = GridBagConstraints.PAGE_START;
124
        JPanel fieldsPanel = new JPanel();
125
        fieldsPanel.setLayout(new GridBagLayout());
126
        int gridy = 0;
127
        List<DynFormFieldDefinition> fields = this.getDefinition().getDefinitions();
128
        for (DynFormFieldDefinition fieldDefinition : fields) {
131 129
            if (fieldDefinition.isHidden()) {
132 130
                continue;
133 131
            }
......
144 142
            if (jfield instanceof AbstractJDynFormField) {
145 143
                ((AbstractJDynFormField) jfield).setForm(this);
146 144
            }
145
            jfield.addListener(this);
147 146
            if (this.isReadOnly()) {
148
                jfield.setReadOnly(true);
147
                jfield.setReadOnly(this.isReadOnly());
148
            }
149
            List<Action> customActions = getCustomActionsForDataType(fieldDefinition.getDataType());
150
            if (customActions != null && !customActions.isEmpty()) {
151
                for (Action customAction : customActions) {
152
                    if (customAction != null) {
153
                        jfield.addActionToPopupMenu((String) customAction.getValue(Action.NAME), customAction);
154
                    } else {
155
                        jfield.addSeparatorToPopupMenu();
156
                    }
157
                }
158
            }
159
            String sep = jfield.getSeparatorTitleToUseBefore();
160
            if( !StringUtils.isBlank(sep) ) {
161
                c.gridx = 0;
162
                c.gridy = gridy;
163
                c.gridwidth = 2;
164
                c.gridheight = 1;
165
                c.fill = GridBagConstraints.HORIZONTAL;
166
                c.weightx = 1;
167
                c.weighty = 0;
168
                fieldsPanel.add(toolsSwingManager.createTitledSeparator(sep), c);
169
                gridy++;
170
            }
171
            if( jfield.useEmptyLabel() ) {
172
                c.gridx = 0;
173
                c.gridy = gridy;
174
                c.gridwidth = 2;
175
                c.gridheight = 1;
149 176
            } else {
150
                jfield.setReadOnly(fieldDefinition.isReadOnly());
177
                c.gridx = 0;
178
                c.gridy = gridy;
179
                c.gridwidth = 1;
180
                c.gridheight = 1;
181
                c.fill = GridBagConstraints.HORIZONTAL;
182
                c.weightx = 0;
183
                c.weighty = 0;
184
                jfield.getJLabel().setAlignmentY(Component.TOP_ALIGNMENT);
185
                fieldsPanel.add(jfield.getJLabel(), c);
186
                c.gridx = 1;
187
                c.gridy = gridy;
188
                c.gridwidth = 1;
189
                c.gridheight = 1;
151 190
            }
152
            jfield.addListener(this);
153
            double resizeWeight = jfield.getResizeWeight();
154
            if( resizeWeight>0 ) {
155
                builder.appendRow(new RowSpec(
156
                    RowSpec.FILL,
157
                    builder.getLayout().getRowSpec(1).getSize(),
158
                    resizeWeight)
159
                );
160
                builder.append(jfield.getJLabel());
161
                builder.add(
162
                        jfield.asJComponent(), 
163
                        new CellConstraints(
164
                            builder.getColumn(), 
165
                            builder.getRow(),
166
                            CellConstraints.FILL,
167
                            CellConstraints.FILL
168
                        )
169
                );
170
                builder.nextColumn();
191
            double weighty = jfield.getResizeWeight();
192
            if( weighty>0 ) {
193
                c.fill = GridBagConstraints.BOTH;
194
                c.weightx = 1;
195
                c.weighty = weighty;
196
                fieldsPanel.add(jfield.asJComponent(), c);
171 197
            } else {
172
                builder.append(jfield.getJLabel(), jfield.asJComponent());
198
                c.fill = GridBagConstraints.HORIZONTAL;
199
                c.weightx = 1;
200
                c.weighty = 0;
201
                fieldsPanel.add(jfield.asJComponent(), c);
173 202
            }
174 203
            this.components.put(jfield.getName(), jfield);
204
            gridy++;
205

  
175 206
        }
176
        return builder.getPanel();
207
        return fieldsPanel;
177 208
    }
178 209

  
179 210
    private JComponent getFieldsContainerUseSeparators() throws ServiceException {
211
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
180 212
        List<String> groups = this.getDefinition().getGroups();
181

  
182
        FormLayout layout = new FormLayout(
183
                "left:pref,  8px,  fill:80dlu:grow", "pref");
184

  
185
        DefaultFormBuilder builder = new DefaultFormBuilder(layout);
186
        builder.defaultRowSpec(new RowSpec(
187
                RowSpec.TOP,
188
                builder.getLayout().getRowSpec(1).getSize(),
189
                builder.getLayout().getRowSpec(1).getResizeWeight()));
190

  
213
        GridBagConstraints c = new GridBagConstraints();
214
        c.insets = new Insets(2, 2, 2, 2);
215
        c.anchor = GridBagConstraints.PAGE_START;
216
        JPanel fieldsPanel = new JPanel();
217
        fieldsPanel.setLayout(new GridBagLayout());
218
        int gridy = 0;
191 219
        for (String group : groups) {
192
            boolean firstfield = true;
193
            List fields = this.getDefinition().getDefinitions(group);
194
            Iterator it = fields.iterator();
195
            while (it.hasNext()) {
196
                DynFormFieldDefinition fieldDefinition = (DynFormFieldDefinition) it.next();
220
            boolean firstField = true;
221
            List<DynFormFieldDefinition> fields = this.getDefinition().getDefinitions(group);
222
            for (DynFormFieldDefinition fieldDefinition : fields) {
197 223
                if (fieldDefinition.isHidden()) {
198 224
                    continue;
199 225
                }
......
215 241
                    jfield.setReadOnly(this.isReadOnly());
216 242
                }
217 243

  
218
                List<Action> customActions = getCustomFields(fieldDefinition.getDataType());
219

  
244
                List<Action> customActions = getCustomActionsForDataType(fieldDefinition.getDataType());
220 245
                if (customActions != null && !customActions.isEmpty()) {
221
                    Iterator it2 = customActions.iterator();
222
                    while (it2.hasNext()) {
223
                        Object obj = it2.next();
224
                        if (obj != null) {
225
                            Action act = (Action) obj;
226
                            jfield.addActionToPopupMenu((String) act.getValue(Action.NAME), act);
246
                    for (Action customAction : customActions) {
247
                        if (customAction != null) {
248
                            jfield.addActionToPopupMenu((String) customAction.getValue(Action.NAME), customAction);
227 249
                        } else {
228 250
                            jfield.addSeparatorToPopupMenu();
229 251
                        }
230 252
                    }
231 253
                }
232
                if( firstfield ) {
233
                    firstfield = false;
234
                    builder.appendSeparator(group);
254
                if( firstField ) {
255
                    firstField = false;
256
                    c.gridx = 0;
257
                    c.gridy = gridy;
258
                    c.gridwidth = 2;
259
                    c.gridheight = 1;
260
                    c.fill = GridBagConstraints.HORIZONTAL;
261
                    c.weightx = 1;
262
                    c.weighty = 0;
263
                    fieldsPanel.add(toolsSwingManager.createTitledSeparator(group), c);
264
                    gridy++;
235 265
                }
236
                double resizeWeight = jfield.getResizeWeight();
237
                if( resizeWeight>0 ) {
238
                    builder.appendRow(new RowSpec(
239
                        RowSpec.FILL,
240
                        builder.getLayout().getRowSpec(1).getSize(),
241
                        resizeWeight)
242
                    );
243
                    builder.append(jfield.getJLabel());
244
                    builder.add(
245
                            jfield.asJComponent(), 
246
                            new CellConstraints(
247
                                builder.getColumn(), 
248
                                builder.getRow(),
249
                                CellConstraints.FILL,
250
                                CellConstraints.FILL
251
                            )
252
                    );
253
                    builder.nextColumn();
266
                String sep = jfield.getSeparatorTitleToUseBefore();
267
                if( !StringUtils.isBlank(sep) ) {
268
                    c.gridx = 0;
269
                    c.gridy = gridy;
270
                    c.gridwidth = 2;
271
                    c.gridheight = 1;
272
                    c.fill = GridBagConstraints.HORIZONTAL;
273
                    c.weightx = 1;
274
                    c.weighty = 0;
275
                    fieldsPanel.add(toolsSwingManager.createTitledSeparator(sep), c);
276
                    gridy++;
277
                }
278
                if( jfield.useEmptyLabel() ) {
279
                    c.gridx = 0;
280
                    c.gridy = gridy;
281
                    c.gridwidth = 2;
282
                    c.gridheight = 1;
254 283
                } else {
255
                    builder.append(jfield.getJLabel(), jfield.asJComponent());
284
                    c.gridx = 0;
285
                    c.gridy = gridy;
286
                    c.gridwidth = 1;
287
                    c.gridheight = 1;
288
                    c.fill = GridBagConstraints.HORIZONTAL;
289
                    c.weightx = 0;
290
                    c.weighty = 0;
291
                    fieldsPanel.add(jfield.getJLabel(), c);
292
                    c.gridx = 1;
293
                    c.gridy = gridy;
294
                    c.gridwidth = 1;
295
                    c.gridheight = 1;
256 296
                }
297
                double weighty = jfield.getResizeWeight();
298
                if( weighty>0 ) {
299
                    c.fill = GridBagConstraints.BOTH;
300
                    c.weightx = 1;
301
                    c.weighty = weighty;
302
                    fieldsPanel.add(jfield.asJComponent(), c);
303
                } else {
304
                    c.fill = GridBagConstraints.HORIZONTAL;
305
                    c.weightx = 1;
306
                    c.weighty = 0;
307
                    fieldsPanel.add(jfield.asJComponent(), c);
308
                }
257 309
                this.components.put(jfield.getName(), jfield);
310
                gridy++;
258 311
            }
259 312
        }
260
        return builder.getPanel();
313
        return fieldsPanel;
261 314
    }
262 315

  
263 316
    private JComponent getFieldsContainerUseTabs() throws ServiceException {
264 317

  
265 318
        JTabbedPane tabbedPane = new JTabbedPane();
266
        tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
267 319
        if (this.getDefinition().getTags().has("TabPlacement")) {
268 320
            try {
269 321
                tabbedPane.setTabPlacement(this.getDefinition().getTags().getInt("TabPlacement"));
......
271 323
                // Ignorada
272 324
            }
273 325
        }
326
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
274 327
        I18nManager i18n = ToolsLocator.getI18nManager();
275 328
        List<String> groups = this.getDefinition().getGroups();
329
        GridBagConstraints c = new GridBagConstraints();
330
        c.insets = new Insets(2, 2, 2, 2);
331
        c.anchor = GridBagConstraints.PAGE_START;
276 332
        for (String group : groups) {
277
            FormLayout layout = new FormLayout(
278
                    "left:pref,  8px,  fill:80dlu:grow", "pref");
279
            DefaultFormBuilder builder = new DefaultFormBuilder(layout);
280
            builder.defaultRowSpec(new RowSpec(
281
                    RowSpec.TOP,
282
                    builder.getLayout().getRowSpec(1).getSize(),
283
                    builder.getLayout().getRowSpec(1).getResizeWeight()));
284
            List fields = this.getDefinition().getDefinitions(group);
285
            boolean hasFields = false;
286
            Iterator it = fields.iterator();
287
            while (it.hasNext()) {
288
                DynFormFieldDefinition fieldDefinition = (DynFormFieldDefinition) it.next();
333
            JPanel fieldsPanel = new JPanel();
334
            GridBagLayout gridbag = new GridBagLayout();
335
            fieldsPanel.setLayout(gridbag);
336
            List<DynFormFieldDefinition> fields = this.getDefinition().getDefinitions(group);
337
            int gridy = 0;
338
            for (DynFormFieldDefinition fieldDefinition : fields) {
289 339
                if (fieldDefinition.isHidden()) {
290 340
                    continue;
291 341
                }
......
307 357
                if (this.isReadOnly()) {
308 358
                    jfield.setReadOnly(this.isReadOnly());
309 359
                }
310
                hasFields = true;
311
                Tags tags = jfield.getDefinition().getTags();
312
                if( tags!=null ) {
313
                    String sep = tags.getString(TAG_DYNFORM_SEPARATOR, null);
314
                    if( !StringUtils.isBlank(sep) ) {
315
                        builder.appendSeparator(i18n.getTranslation(sep));
360
                List<Action> customActions = getCustomActionsForDataType(fieldDefinition.getDataType());
361
                if (customActions != null && !customActions.isEmpty()) {
362
                    for (Action customAction : customActions) {
363
                        if (customAction != null) {
364
                            jfield.addActionToPopupMenu((String) customAction.getValue(Action.NAME), customAction);
365
                        } else {
366
                            jfield.addSeparatorToPopupMenu();
367
                        }
316 368
                    }
369
                }
370
                String sep = jfield.getSeparatorTitleToUseBefore();
371
                if( !StringUtils.isBlank(sep) ) {
372
                    c.gridx = 0;
373
                    c.gridy = gridy;
374
                    c.gridwidth = 2;
375
                    c.gridheight = 1;
376
                    c.fill = GridBagConstraints.HORIZONTAL;
377
                    c.weightx = 1;
378
                    c.weighty = 0;
379
                    fieldsPanel.add(toolsSwingManager.createTitledSeparator(sep), c);
380
                    gridy++;
317 381
                }                
318
                double resizeWeight = jfield.getResizeWeight();
319
                if( resizeWeight>0 ) {
320
                    builder.appendRow(new RowSpec(
321
                        RowSpec.FILL,
322
                        builder.getLayout().getRowSpec(1).getSize(),
323
                        resizeWeight)
324
                    );
325
                    builder.append(jfield.getJLabel());
326
                    builder.add(
327
                            jfield.asJComponent(), 
328
                            new CellConstraints(
329
                                builder.getColumn(), 
330
                                builder.getRow(),
331
                                CellConstraints.FILL,
332
                                CellConstraints.FILL
333
                            )
334
                    );
335
                    builder.nextColumn();
382
                if( jfield.useEmptyLabel() ) {
383
                    c.gridx = 0;
384
                    c.gridy = gridy;
385
                    c.gridwidth = 2;
386
                    c.gridheight = 1;
336 387
                } else {
337
                    builder.append(jfield.getJLabel(), jfield.asJComponent());
388
                    c.gridx = 0;
389
                    c.gridy = gridy;
390
                    c.gridwidth = 1;
391
                    c.gridheight = 1;
392
                    c.fill = GridBagConstraints.HORIZONTAL;
393
                    c.weightx = 0;
394
                    c.weighty = 0;
395
                    jfield.getJLabel().setAlignmentY(Component.TOP_ALIGNMENT);
396
                    fieldsPanel.add(jfield.getJLabel(), c);
397
                    c.gridx = 1;
398
                    c.gridy = gridy;
399
                    c.gridwidth = 1;
400
                    c.gridheight = 1;
338 401
                }
339

  
402
                double weighty = jfield.getResizeWeight();
403
                if( weighty>0 ) {
404
                    c.fill = GridBagConstraints.BOTH;
405
                    c.weightx = 1;
406
                    c.weighty = weighty;
407
                    fieldsPanel.add(jfield.asJComponent(), c);
408
                } else {
409
                    c.fill = GridBagConstraints.HORIZONTAL;
410
                    c.weightx = 1;
411
                    c.weighty = 0;
412
                    fieldsPanel.add(jfield.asJComponent(), c);
413
                }
340 414
                this.components.put(jfield.getName(), jfield);
415
                gridy++;
341 416
            }
342
            if( hasFields ) {
417
            if( gridy>0 ) {
343 418
                String tablabel = group;
344 419
                if (StringUtils.isEmpty(tablabel)) {
345 420
                    tablabel = ToolsLocator.getI18nManager().getTranslation("General");
346 421
                }
347 422
                tablabel = i18n.getTranslation(tablabel);
348
                tabbedPane.addTab(tablabel, builder.getPanel());
423
                
424
                // Con esto forzamos a alinear los componentes arriba.
425
                c.gridx = 0;
426
                c.gridy = gridy;
427
                c.gridwidth = 1;
428
                c.gridheight = 1;
429
                c.fill = GridBagConstraints.VERTICAL;
430
                c.weightx = 0;
431
                c.weighty = 0.001;
432
                fieldsPanel.add(new JLabel(), c);
433
                
434
                tabbedPane.addTab(tablabel,fieldsPanel);
349 435
            }
350 436
        }
351 437

  
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.api/src/main/java/org/gvsig/tools/dynform/JDynFormField.java
46 46
	
47 47
	public JComponent getJLabel();
48 48

  
49
        public boolean useEmptyLabel();
50
        
51
        public String getSeparatorTitleToUseBefore();
52
        
49 53
	public boolean hasValidValue();
50 54
	
51 55
	public void setValue(Object value);

Also available in: Unified diff