svn-gvsig-desktop / trunk / extensions / extMetadata / src / org / gvsig / metadata / extension / gui / MDBasicGUIPanel.java @ 25412
History | View | Annotate | Download (3.58 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
|
26 |
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
|
27 |
* Universitat Jaume I
|
28 |
* {{Task}}
|
29 |
*/
|
30 |
|
31 |
package org.gvsig.metadata.extension.gui; |
32 |
|
33 |
import java.util.ArrayList; |
34 |
import java.util.Iterator; |
35 |
import java.util.List; |
36 |
import java.util.Map; |
37 |
|
38 |
import javax.swing.BorderFactory; |
39 |
import javax.swing.JComponent; |
40 |
import javax.swing.JLabel; |
41 |
import javax.swing.JPanel; |
42 |
import javax.swing.JTextField; |
43 |
import javax.swing.border.EtchedBorder; |
44 |
import javax.swing.border.TitledBorder; |
45 |
|
46 |
import net.miginfocom.swing.MigLayout; |
47 |
|
48 |
import org.gvsig.metadata.extended.registry.MDRegistry; |
49 |
import org.gvsig.metadata.extended.registry.MDRegistryImpl; |
50 |
import org.gvsig.metadata.extended.registry.objects.MDDefinition; |
51 |
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition; |
52 |
|
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
55 |
|
56 |
|
57 |
|
58 |
public class MDBasicGUIPanel extends JPanel{ |
59 |
|
60 |
private static final long serialVersionUID = -2005251151677378280L; |
61 |
private FLayer layer;
|
62 |
private List<JComponent> uiElements; |
63 |
|
64 |
|
65 |
public MDBasicGUIPanel(FLayer fl) {
|
66 |
this.layer = fl;
|
67 |
this.uiElements = new ArrayList<JComponent>(); |
68 |
|
69 |
System.out.println("Metadata for: " + layer.getName()); |
70 |
|
71 |
MDRegistry reg = new MDRegistryImpl();
|
72 |
MDDefinition mdd = reg.getMDDefinition("FLayer");
|
73 |
|
74 |
//MDDefinition mdd2 = reg.getMDDefinition("NO_EXISTE");
|
75 |
|
76 |
setBorder(BorderFactory.createTitledBorder(
|
77 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
78 |
PluginServices.getText(this, mdd.getName()),
|
79 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
80 |
TitledBorder.DEFAULT_POSITION, null, null) |
81 |
); |
82 |
setLayout(new MigLayout());
|
83 |
|
84 |
Iterator it = mdd.iterator();
|
85 |
while (it.hasNext()) {
|
86 |
Map.Entry e = (Map.Entry)it.next(); |
87 |
add(new JLabel(((MDElementDefinition)e.getValue()).getName() + ": ")); |
88 |
JTextField auxJTF = new JTextField(20); |
89 |
auxJTF.setEnabled(false);
|
90 |
|
91 |
// Provisional, el valor se deberia leer del respectivo atributo de la capa
|
92 |
auxJTF.setText(((MDElementDefinition)e.getValue()).getDefaultValue().toString()); |
93 |
|
94 |
add(auxJTF, "wrap");
|
95 |
uiElements.add(auxJTF); |
96 |
} |
97 |
|
98 |
} |
99 |
|
100 |
|
101 |
public void allowEdition() { |
102 |
Iterator it = uiElements.iterator();
|
103 |
while (it.hasNext()) {
|
104 |
JComponent jc = (JComponent)it.next(); |
105 |
jc.setEnabled(true);
|
106 |
} |
107 |
} |
108 |
|
109 |
public void closeEdition() { |
110 |
Iterator it = uiElements.iterator();
|
111 |
while (it.hasNext()) {
|
112 |
JComponent jc = (JComponent)it.next(); |
113 |
jc.setEnabled(false);
|
114 |
} |
115 |
} |
116 |
|
117 |
public void saveChanges() { |
118 |
// TODO Auto-generated method stub
|
119 |
|
120 |
} |
121 |
|
122 |
} |