Revision 14887

View differences:

tags/tmp_build/applications/appCatalogAndGazetteerClient/config/ApplicationContextAlone.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3

  
4
<beans>
5

  
6
  <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
7
    <property name="location"><value>config/TestContext.properties</value></property>
8
  </bean>
9

  
10
  <!-- ========================= GENERAL DEFINITIONS ========================= -->
11

  
12
  <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
13
    <property name="basename"><value>messages</value></property>
14
  </bean>
15

  
16

  
17
  <!-- ========================= PERSISTENCE DEFINITIONS ========================= -->
18

  
19
  <!-- ========================= BUSINESS DEFINITIONS ========================= -->
20

  
21
  <bean id="OIDRegister" class="org.jzkit.a2j.codec.util.OIDRegister">
22
    <constructor-arg index="0"><value>/es/gva/cit/catalogClient/protocols/context/a2j.properties</value></constructor-arg>
23
  </bean>
24

  
25
  <!-- conversion rules -->
26
  <bean id="RPNToInternalRules" class="org.jzkit.util.PropsHolder">
27
    <constructor-arg index="0"><value>/es/gva/cit/catalogClient/protocols/context/InternalAttrTypes.properties</value></constructor-arg>
28
  </bean>
29

  
30
  <bean id="InternalToType1ConversionRules" class="org.jzkit.z3950.QueryModel.PropsBasedInternalToType1ConversionRules">
31
    <constructor-arg index="0"><value>/es/gva/cit/catalogClient/protocols/context/InternalToType1Rules.properties</value></constructor-arg>
32
  </bean>
33

  
34
</beans>
0 35

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/config/ApplicationContext.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3
<beans>
4
	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
5
    	<property name="location"><value>gvSIG/extensiones/es.gva.cit.gvsig.catalogClient/config/TestContext.properties</value></property>
6
	</bean>
7
<!-- ========================= GENERAL DEFINITIONS ========================= -->
8
	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
9
    	<property name="basename"><value>messages</value></property>
10
	</bean>
11
<!-- ========================= PERSISTENCE DEFINITIONS ========================= -->
12

  
13
<!-- ========================= BUSINESS DEFINITIONS ========================= -->
14

  
15
	<bean id="OIDRegister" class="org.jzkit.a2j.codec.util.OIDRegister">
16
    	<constructor-arg index="0"><value>/es/gva/cit/catalogClient/protocols/context/a2j.properties</value></constructor-arg>
17
	</bean>
18

  
19
<!-- conversion rules -->
20
	<bean id="RPNToInternalRules" class="org.jzkit.util.PropsHolder">
21
    	<constructor-arg index="0"><value>/es/gva/cit/catalogClient/protocols/context/InternalAttrTypes.properties</value></constructor-arg>
22
	</bean>
23

  
24
  	<bean id="InternalToType1ConversionRules" class="org.jzkit.z3950.QueryModel.PropsBasedInternalToType1ConversionRules">
25
    	<constructor-arg index="0"><value>/es/gva/cit/catalogClient/protocols/context/InternalToType1Rules.properties</value></constructor-arg>
26
	</bean>
27
</beans>
0 28

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/build.number
1
#Build Number for ANT. Do not edit!
2
#Thu Sep 13 16:14:10 CEST 2007
3
build.number=1015
0 4

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/src/es/gva/cit/catalogClient/utils/xmlTreeTable/XMLTreeCellRenderer.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package es.gva.cit.catalogClient.utils.xmlTreeTable;
43

  
44
/**
45
 * 
46
 * 
47
 * 
48
 * @author Jorge Piera Llodra (piera_jor@gva.es)
49
 */
50
public class XMLTreeCellRenderer extends javax.swing.tree.DefaultTreeCellRenderer {
51

  
52
/**
53
 * 
54
 * 
55
 */
56
    public  XMLTreeCellRenderer() {        
57
        this.setClosedIcon(null);
58
        this.setOpenIcon(null);
59
        this.setLeafIcon(null);
60
    } 
61
 }
0 62

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/src/es/gva/cit/catalogClient/utils/xmlTreeTable/XMLTreeTable.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package es.gva.cit.catalogClient.utils.xmlTreeTable;
43
import javax.swing.JComponent;
44
import javax.swing.JTree;
45
import next.swing.JTreeTable;
46
import next.swing.TreeTableModel;
47

  
48
/**
49
 * 
50
 * 
51
 * 
52
 * @author Jorge Piera Llodra (piera_jor@gva.es)
53
 */
54
public class XMLTreeTable extends JTreeTable {
55

  
56
/**
57
 * 
58
 * 
59
 * 
60
 * @param treeTableModel 
61
 */
62
    public  XMLTreeTable(TreeTableModel treeTableModel) {        
63
        super(treeTableModel);
64
        tree.setCellRenderer(new XMLTreeCellRenderer());
65
        setDefaultEditor(JComponent.class, new XMLTreeTableCellEditor());
66
    } 
67

  
68
/**
69
 * 
70
 * 
71
 * 
72
 * @return 
73
 */
74
    public JTree getTree() {        
75
        return tree;
76
    } 
77

  
78
/**
79
 * 
80
 * 
81
 * 
82
 * @return 
83
 * @param x 
84
 * @param y 
85
 */
86
    public boolean isCellEditable(int x, int y) {        
87
        return true;
88
    } 
89
 }
0 90

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/src/es/gva/cit/catalogClient/utils/xmlTreeTable/XMLTreeTableModel.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package es.gva.cit.catalogClient.utils.xmlTreeTable;
43
import es.gva.cit.catalogClient.metadataXML.XMLNode;
44
import es.gva.cit.catalogClient.utils.Strings;
45
import java.awt.Font;
46
import java.util.Enumeration;
47
import java.util.Vector;
48
import javax.swing.JEditorPane;
49
import javax.swing.JLabel;
50
import javax.swing.JScrollPane;
51
import javax.swing.JTree;
52
import javax.swing.tree.DefaultMutableTreeNode;
53
import javax.swing.tree.TreePath;
54
import next.swing.AbstractTreeTableModel;
55
import next.swing.TreeTableModel;
56
import org.amic.util.date.Date;
57

  
58
/**
59
 * 
60
 * 
61
 * 
62
 * @author Jorge Piera Llodra (piera_jor@gva.es)
63
 */
64
public class XMLTreeTableModel extends AbstractTreeTableModel {
65

  
66
/**
67
 * 
68
 * 
69
 */
70
    private Vector columns = null;
71

  
72
/**
73
 * 
74
 * 
75
 */
76
    private String[] allowed = null;
77

  
78
/**
79
 * 
80
 * 
81
 */
82
    private String[] forbidden = null;
83

  
84
/**
85
 * 
86
 * 
87
 */
88
    private boolean dynamic = false;
89

  
90
/**
91
 * Creates new XmlTreeTableModel
92
 * 
93
 * 
94
 * @param node 
95
 */
96
    public  XMLTreeTableModel(XMLNode node) {        
97
        this(node, -1, null, null);
98
    } 
99

  
100
/**
101
 * 
102
 * 
103
 * 
104
 * @param node 
105
 * @param level 
106
 * @param allowed 
107
 * @param forbidden 
108
 */
109
    public  XMLTreeTableModel(XMLNode node, int level, String[] allowed, String[] forbidden) {        
110
        super(new DefaultMutableTreeNode(node));
111
        this.allowed = allowed;
112
        this.forbidden = forbidden;
113
        processChildren((DefaultMutableTreeNode) getRoot(), level);
114
    } 
115

  
116
/**
117
 * 
118
 * 
119
 */
120
    public final int ALIGN_LEFT = JLabel.LEFT;
121

  
122
/**
123
 * 
124
 * 
125
 */
126
    public final int ALIGN_RIGHT = JLabel.RIGHT;
127

  
128
/**
129
 * 
130
 * 
131
 */
132
    public final int ALIGN_CENTER = JLabel.CENTER;
133

  
134
/**
135
 * 
136
 * 
137
 * 
138
 * @param value 
139
 */
140
    public void setDynamic(boolean value) {        
141
        dynamic = value;
142
    } 
143

  
144
/**
145
 * 
146
 * 
147
 * 
148
 * @return 
149
 * @param node 
150
 */
151
    public boolean isLeaf(Object node) {        
152
        return (getChildCount(node) == 0) && !dynamic;
153
    } 
154

  
155
/**
156
 * 
157
 * 
158
 * 
159
 * @return 
160
 * @param node 
161
 * @param level 
162
 */
163
    public boolean processChildren(DefaultMutableTreeNode node, int level) {        
164
        if (level == 0) {
165
            return true;
166
        }
167
        boolean doIt = true;
168
        XMLNode n = (XMLNode) node.getUserObject();
169
        if (allowed != null) {
170
            String name = n.getName();
171
            doIt = false;
172
            for (int i = 0; i < allowed.length; i++)
173
                if (allowed[i].equals(name)) {
174
                    doIt = true;
175
                    break;
176
                }
177
        }
178
        if (forbidden != null) {
179
            String name = n.getName();
180
            for (int i = 0; i < forbidden.length; i++)
181
                if (forbidden[i].equals(name)) {
182
                    doIt = false;
183
                    break;
184
                }
185
        }
186
        if (!doIt) {
187
            return false;
188
        }
189
        XMLNode[] nodes = n.getSubnodes();
190
        DefaultMutableTreeNode newNode;
191
        for (int i=0 ; i<nodes.length ; i++) {
192
            newNode = new DefaultMutableTreeNode(nodes[i]);
193
            if (processChildren(newNode, level - 1)) {
194
                node.add(newNode);
195
            }
196
        }
197
        return true;
198
    } 
199

  
200
/**
201
 * 
202
 * 
203
 * 
204
 * @param ctt 
205
 */
206
    public void configureView(XMLTreeTable ctt) {        
207
        Column col;
208
        javax.swing.table.TableColumnModel tcm = ctt.getColumnModel();
209
        ctt.setRowHeight(20);
210
        int total = 0;
211
        for (int i = 1; i < tcm.getColumnCount(); i++) {
212
            col = ((Column) columns.elementAt(i - 1));
213
            tcm.getColumn(i).setPreferredWidth(50);
214
            total += col.width;
215
            tcm.getColumn(i).setCellRenderer(new XMLTreeTableCellRenderer());
216
        }
217
        tcm.getColumn(0).setWidth(100);
218
        setExpandedTree((DefaultMutableTreeNode) getRoot(), ctt.getTree());
219
    } 
220

  
221
/**
222
 * 
223
 * 
224
 * 
225
 * @return 
226
 * @param node 
227
 * @param tree 
228
 */
229
    public boolean setExpandedTree(DefaultMutableTreeNode node, JTree tree) {        
230
        boolean isExpanded = false;
231
        Enumeration children = node.children();
232
        while (children.hasMoreElements()) {
233
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
234
            if (setExpandedTree(child, tree) && (isExpanded == false)) {
235
                isExpanded = true;
236
            }
237
        }
238
        if (node.isLeaf() && (isValueAt(node) || isAttributeAt(node))) {
239
            tree.expandPath(new TreePath(node.getPath()));
240
            return true;
241
        }
242
        if (isExpanded) {
243
            tree.expandPath(new TreePath(node.getPath()));
244
        }
245
        return isExpanded;
246
    } 
247

  
248
/**
249
 * 
250
 * 
251
 * 
252
 * @param name 
253
 * @param attribute 
254
 * @param label 
255
 * @param width 
256
 */
257
    public void addJScrollPaneColumn(String name, String attribute, String label, int width) {        
258
        addColumn(new Column(name, attribute, label, ALIGN_LEFT, width,
259
                JScrollPane.class, null));
260
    } 
261

  
262
/**
263
 * 
264
 * 
265
 * 
266
 * @param name 
267
 * @param attribute 
268
 * @param label 
269
 * @param width 
270
 */
271
    public void addStringColumn(String name, String attribute, String label, int width) {        
272
        addColumn(new Column(name, attribute, label, ALIGN_LEFT, width,
273
                String.class, null));
274
    } 
275

  
276
/**
277
 * 
278
 * 
279
 * 
280
 * @param name 
281
 * @param attribute 
282
 * @param label 
283
 * @param width 
284
 * @param format 
285
 */
286
    public void addNumberColumn(String name, String attribute, String label, int width, String format) {        
287
        addColumn(new Column(name, attribute, label, ALIGN_RIGHT, width,
288
                Double.class, format));
289
    } 
290

  
291
/**
292
 * 
293
 * 
294
 * 
295
 * @param name 
296
 * @param attribute 
297
 * @param label 
298
 * @param width 
299
 * @param format 
300
 */
301
    public void addDateColumn(String name, String attribute, String label, int width, String format) {        
302
        addColumn(new Column(name, attribute, label, ALIGN_LEFT, width,
303
                Date.class, format));
304
    } 
305

  
306
/**
307
 * 
308
 * 
309
 * 
310
 * @param column 
311
 */
312
    public void addColumn(Column column) {        
313
        if (columns == null) {
314
            columns = new Vector();
315
        }
316
        columns.add(column);
317
    } 
318

  
319
/**
320
 * 
321
 * 
322
 * 
323
 * @return 
324
 * @param parent 
325
 */
326
    public int getChildCount(Object parent) {        
327
        return ((DefaultMutableTreeNode) parent).getChildCount();
328
    } 
329

  
330
/**
331
 * 
332
 * 
333
 * 
334
 * @return 
335
 * @param parent 
336
 * @param index 
337
 */
338
    public Object getChild(Object parent, int index) {        
339
        return ((DefaultMutableTreeNode) parent).getChildAt(index);
340
    } 
341

  
342
/**
343
 * 
344
 * 
345
 * 
346
 * @return 
347
 * @param column 
348
 */
349
    public String getColumnName(int column) {        
350
        if (column == 0) {
351
            return "";
352
        }
353
        return ((Column) columns.elementAt(column - 1)).label;
354
    } 
355

  
356
/**
357
 * 
358
 * 
359
 * 
360
 * @return 
361
 * @param column 
362
 */
363
    public Class getColumnClass(int column) {        
364
        if (column == 0) {
365
            return TreeTableModel.class;
366
        }
367
        return ((Column) columns.elementAt(column - 1)).jClass;
368
    } 
369

  
370
/**
371
 * 
372
 * 
373
 * 
374
 * @return 
375
 * @param node 
376
 */
377
    public boolean isValueAt(Object node) {        
378
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) node;
379
        if (currentNode.getUserObject() instanceof XMLNode) {
380
            XMLNode xr = (XMLNode) currentNode.getUserObject();
381
            if (xr != null) {
382
                if (xr.getText() != null) {
383
                    if (!(Strings.replace(xr.getText(), " ", "").equals(""))) {
384
                        return true;
385
                    }
386
                }
387
            }
388
        }
389
        return false;
390
    } 
391

  
392
/**
393
 * 
394
 * 
395
 * 
396
 * @return 
397
 * @param node 
398
 */
399
    public boolean isAttributeAt(Object node) {        
400
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) node;
401
        if (currentNode.getUserObject() instanceof XMLNode) {
402
            XMLNode xr = (XMLNode) currentNode.getUserObject();
403
            if (xr != null) {
404
                if (getAttribute(xr) != null) {
405
                    if (!(Strings.replace(getAttribute(xr),
406
                                " ", "").equals(""))) {
407
                        return true;
408
                    }
409
                }
410
            }
411
        }
412
        return false;
413
    } 
414

  
415
/**
416
 * 
417
 * 
418
 * 
419
 * @return 
420
 * @param node 
421
 */
422
    public String getValueAt(Object node) {        
423
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) node;
424
        if (currentNode.getUserObject() instanceof XMLNode) {
425
            XMLNode xr = (XMLNode) currentNode.getUserObject();
426
            
427
            return xr.getText();
428
        }
429
        return null;
430
    } 
431

  
432
/**
433
 * 
434
 * 
435
 * 
436
 * @return 
437
 * @param node 
438
 * @param column 
439
 */
440
    public Object getValueAt(Object node, int column) {        
441
        //JScrollPane
442
        JEditorPane editor = new JEditorPane();
443
        editor.setEditable(false);
444
        JScrollPane scroll = new JScrollPane(editor);
445
        scroll.setBorder(null);
446
        //JLabel
447
        JLabel text = new JLabel();
448
        text.setFont(new Font(null, Font.PLAIN, 12));
449
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) node;
450
        if (currentNode.getUserObject() instanceof XMLNode) {
451
            XMLNode xr = (XMLNode) currentNode.getUserObject();
452
            if (column == 0) {
453
                return xr.toString();
454
            }
455
            Column col = (Column) columns.elementAt(column - 1);
456
            String att = col.attribute;
457
            try {
458
                if (att.equals("tag-name")) {
459
                    if (xr.getName().trim().length() > 40) {
460
                        editor.setText(xr.getName());
461
                        editor.setCaretPosition(0);
462
                        return scroll;
463
                    }
464
                    text.setText(xr.getName());
465
                    
466
                    return text;
467
                } else if (att.equals("tag-value")) {
468
                    if (xr.getText().trim().length() > 40) {
469
                        editor.setText(xr.getText());
470
                        editor.setCaretPosition(0);
471
                        return scroll;
472
                    }
473
                    text.setText(xr.getText());
474
                    return text;
475
                } else {
476
                    if (getAttribute(xr).trim().length() > 40) {
477
                        editor.setText(getAttribute(xr));
478
                        editor.setCaretPosition(0);
479
                        return scroll;
480
                    }
481
                    text.setText(getAttribute(xr));
482
                    return text;
483
                }
484
            } catch (Exception ex) {
485
            }
486
        }
487
        return null;
488
    } 
489

  
490
/**
491
 * 
492
 * 
493
 * 
494
 * @return 
495
 * @param node 
496
 */
497
    public String getAttribute(XMLNode node) {        
498
        String attributes = "";
499
        Vector vAttributes = node.getAttributeNames();
500
        
501
        for (int i = 0; i < vAttributes.size(); i++){
502
            String att = (String)vAttributes.get(i);
503
            String val = node.getAttribute(att);
504
            attributes = attributes +
505
                att + "=" + val + " ";
506
        }
507
        return attributes;
508
    } 
509

  
510
/**
511
 * 
512
 * 
513
 * 
514
 * @return 
515
 */
516
    public int getColumnCount() {        
517
        if (columns == null) {
518
            return 1;
519
        }
520
        return columns.size() + 1;
521
    } 
522
/**
523
 * 
524
 * 
525
 */
526
public class Column {
527

  
528
/**
529
 * 
530
 * 
531
 */
532
    int align;
533

  
534
/**
535
 * 
536
 * 
537
 */
538
    int width;
539

  
540
/**
541
 * 
542
 * 
543
 */
544
    Class jClass;
545

  
546
/**
547
 * 
548
 * 
549
 */
550
    String name;
551

  
552
/**
553
 * 
554
 * 
555
 */
556
    String attribute;
557

  
558
/**
559
 * 
560
 * 
561
 */
562
    String label;
563

  
564
/**
565
 * 
566
 * 
567
 */
568
    String format;
569

  
570
/**
571
 * 
572
 * 
573
 * 
574
 * @param name 
575
 * @param attribute 
576
 * @param label 
577
 * @param align 
578
 * @param width 
579
 * @param jClass 
580
 * @param format 
581
 */
582
     Column(String name, String attribute, String label, int align, int width, Class jClass, String format) {        
583
            this.name = name;
584
            this.attribute = attribute;
585
            this.label = label;
586
            this.align = align;
587
            this.width = width;
588
            this.jClass = jClass;
589
            this.format = format;
590
    } 
591
 }
592
 }
0 593

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/src/es/gva/cit/catalogClient/utils/xmlTreeTable/XMLTreeTableCellEditor.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package es.gva.cit.catalogClient.utils.xmlTreeTable;
43
import java.awt.Component;
44
import java.awt.event.MouseEvent;
45
import java.io.Serializable;
46
import java.util.EventObject;
47
import javax.swing.JComponent;
48
import javax.swing.JTable;
49
import javax.swing.JTree;
50
import javax.swing.SwingUtilities;
51
import javax.swing.event.CellEditorListener;
52
import javax.swing.event.ChangeEvent;
53
import javax.swing.event.EventListenerList;
54
import javax.swing.table.TableCellEditor;
55
import javax.swing.tree.TreeCellEditor;
56
//File: JComponentCellEditor.java
57
//Author: Zafir Anjum
58

  
59
/**
60
 * DOCUMENT ME!
61
 * 
62
 * 
63
 * @author $author$
64
 */
65
public class XMLTreeTableCellEditor implements Serializable, TableCellEditor, TreeCellEditor {
66
/**
67
 * 
68
 * 
69
 */
70
    protected EventListenerList listenerList = new EventListenerList();
71
/**
72
 * 
73
 * 
74
 */
75
    protected transient ChangeEvent changeEvent = null;
76
/**
77
 * 
78
 * 
79
 */
80
    protected JComponent editorComponent = null;
81
/**
82
 * 
83
 * 
84
 */
85
    protected JComponent container = null;
86
// Can be tree or table
87

  
88
/**
89
 * DOCUMENT ME!
90
 * 
91
 * 
92
 * @return DOCUMENT ME!
93
 */
94
    public Component getComponent() {        
95
        return editorComponent;
96
    } 
97

  
98
/**
99
 * DOCUMENT ME!
100
 * 
101
 * 
102
 * @return DOCUMENT ME!
103
 */
104
    public Object getCellEditorValue() {        
105
        return editorComponent;
106
    } 
107

  
108
/**
109
 * DOCUMENT ME!
110
 * 
111
 * 
112
 * @return DOCUMENT ME!
113
 * @param anEvent DOCUMENT ME!
114
 */
115
    public boolean isCellEditable(EventObject anEvent) {        
116
        return true;
117
    } 
118

  
119
/**
120
 * DOCUMENT ME!
121
 * 
122
 * 
123
 * @return DOCUMENT ME!
124
 * @param anEvent DOCUMENT ME!
125
 */
126
    public boolean shouldSelectCell(EventObject anEvent) {        
127
        if ((editorComponent != null) && anEvent instanceof MouseEvent &&
128
                (((MouseEvent) anEvent).getID() == MouseEvent.MOUSE_PRESSED)) {
129
            Component dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent,
130
                    3, 3);
131
            MouseEvent e = (MouseEvent) anEvent;
132
            MouseEvent e2 = new MouseEvent(dispatchComponent,
133
                    MouseEvent.MOUSE_RELEASED, e.getWhen() + 100000,
134
                    e.getModifiers(), 3, 3, e.getClickCount(),
135
                    e.isPopupTrigger());
136
            dispatchComponent.dispatchEvent(e2);
137
            e2 = new MouseEvent(dispatchComponent, MouseEvent.MOUSE_CLICKED,
138
                    e.getWhen() + 100001, e.getModifiers(), 3, 3, 1,
139
                    e.isPopupTrigger());
140
            dispatchComponent.dispatchEvent(e2);
141
        }
142
        return false;
143
    } 
144

  
145
/**
146
 * DOCUMENT ME!
147
 * 
148
 * 
149
 * @return DOCUMENT ME!
150
 */
151
    public boolean stopCellEditing() {        
152
        fireEditingStopped();
153
        return true;
154
    } 
155

  
156
/**
157
 * DOCUMENT ME!
158
 * 
159
 */
160
    public void cancelCellEditing() {        
161
        fireEditingCanceled();
162
    } 
163

  
164
/**
165
 * DOCUMENT ME!
166
 * 
167
 * 
168
 * @param l DOCUMENT ME!
169
 */
170
    public void addCellEditorListener(CellEditorListener l) {        
171
        listenerList.add(CellEditorListener.class, l);
172
    } 
173

  
174
/**
175
 * DOCUMENT ME!
176
 * 
177
 * 
178
 * @param l DOCUMENT ME!
179
 */
180
    public void removeCellEditorListener(CellEditorListener l) {        
181
        listenerList.remove(CellEditorListener.class, l);
182
    } 
183

  
184
/**
185
 * DOCUMENT ME!
186
 * 
187
 */
188
    protected void fireEditingStopped() {        
189
        Object[] listeners = listenerList.getListenerList();
190
        // Process the listeners last to first, notifying
191
        // those that are interested in this event
192
        for (int i = listeners.length - 2; i >= 0; i -= 2) {
193
            if (listeners[i] == CellEditorListener.class) {
194
                // Lazily create the event:
195
                if (changeEvent == null) {
196
                    changeEvent = new ChangeEvent(this);
197
                }
198
                ((CellEditorListener) listeners[i + 1]).editingStopped(changeEvent);
199
            }
200
        }
201
    } 
202

  
203
/**
204
 * DOCUMENT ME!
205
 * 
206
 */
207
    protected void fireEditingCanceled() {        
208
        // Guaranteed to return a non-null array
209
        Object[] listeners = listenerList.getListenerList();
210
        // Process the listeners last to first, notifying
211
        // those that are interested in this event
212
        for (int i = listeners.length - 2; i >= 0; i -= 2) {
213
            if (listeners[i] == CellEditorListener.class) {
214
                // Lazily create the event:
215
                if (changeEvent == null) {
216
                    changeEvent = new ChangeEvent(this);
217
                }
218
                ((CellEditorListener) listeners[i + 1]).editingCanceled(changeEvent);
219
            }
220
        }
221
    } 
222
// implements javax.swing.tree.TreeCellEditor
223

  
224
/**
225
 * 
226
 * 
227
 * 
228
 * @return 
229
 * @param tree 
230
 * @param value 
231
 * @param isSelected 
232
 * @param expanded 
233
 * @param leaf 
234
 * @param row 
235
 */
236
    public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {        
237
        tree.convertValueToText(value, isSelected,
238
                expanded, leaf, row, false);
239
        editorComponent = (JComponent) value;
240
        container = tree;
241
        return editorComponent;
242
    } 
243
// implements javax.swing.table.TableCellEditor
244

  
245
/**
246
 * 
247
 * 
248
 * 
249
 * @return 
250
 * @param table 
251
 * @param value 
252
 * @param isSelected 
253
 * @param row 
254
 * @param column 
255
 */
256
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {        
257
        editorComponent = (JComponent) value;
258
        container = table;
259
        return editorComponent;
260
    } 
261
 }
262
// End of class JComponentCellEditor
0 263

  
tags/tmp_build/applications/appCatalogAndGazetteerClient/src/es/gva/cit/catalogClient/utils/xmlTreeTable/XMLTreeTableCellRenderer.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package es.gva.cit.catalogClient.utils.xmlTreeTable;
43
import java.awt.Component;
44
import javax.swing.JComponent;
45
import javax.swing.JTable;
46
import javax.swing.table.TableCellRenderer;
47

  
48
/**
49
 * 
50
 * 
51
 * 
52
 * @author Jorge Piera Llodra (piera_jor@gva.es)
53
 */
54
class XMLTreeTableCellRenderer implements TableCellRenderer {
55
/* (non-Javadoc)
56
     * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
57
     */
58

  
59
/**
60
 * 
61
 * 
62
 * 
63
 * @return 
64
 * @param table 
65
 * @param value 
66
 * @param isSelected 
67
 * @param hasFocus 
68
 * @param row 
69
 * @param column 
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff