svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.metadata.basic / org.gvsig.metadata.basic.swing / org.gvsig.metadata.swing.basic.impl / src / main / java / org / gvsig / metadata / swing / basic / impl / JMetadataEditorPanel.java @ 40608
History | View | Annotate | Download (3.36 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2010 Infrastructures and Transports Department
|
4 |
* of the Valencian Gobernment (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 |
* 2010 Institute of New Imaging Technologies (INIT):
|
26 |
* http://www.init.uji.es
|
27 |
* Geographic Information research group:
|
28 |
* http://www.geoinfo.uji.es
|
29 |
* Universitat Jaume I UJI, Spain
|
30 |
*/
|
31 |
package org.gvsig.metadata.swing.basic.impl; |
32 |
|
33 |
import java.awt.BorderLayout; |
34 |
|
35 |
import javax.swing.JComponent; |
36 |
|
37 |
import org.gvsig.metadata.Metadata; |
38 |
import org.gvsig.metadata.MetadataLocator; |
39 |
import org.gvsig.metadata.MetadataManager; |
40 |
import org.gvsig.metadata.exceptions.MetadataException; |
41 |
import org.gvsig.metadata.swing.basic.api.AbstractSimpleMetadataPanel; |
42 |
import org.gvsig.metadata.swing.basic.api.JMetadataPanel; |
43 |
import org.gvsig.metadata.swing.basic.api.MetadataSwingManager; |
44 |
import org.gvsig.tools.dynobject.exception.DynObjectValidateException; |
45 |
import org.gvsig.tools.service.ServiceException; |
46 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
47 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
48 |
|
49 |
public class JMetadataEditorPanel extends JMetadataPanel { |
50 |
|
51 |
/**
|
52 |
*
|
53 |
*/
|
54 |
private static final long serialVersionUID = -5680452321763343711L; |
55 |
private JDynObjectComponent component;
|
56 |
private JComponent inputComponent; |
57 |
private MetadataManager manager;
|
58 |
|
59 |
public JMetadataEditorPanel(MetadataSwingManager uiManager,
|
60 |
Metadata metadata, boolean isEditable) {
|
61 |
super(uiManager, metadata, isEditable);
|
62 |
} |
63 |
|
64 |
protected AbstractSimpleMetadataPanel createMetadataComponent(
|
65 |
Metadata metadata, boolean doRefresh) {
|
66 |
if (metadata == null) { |
67 |
metadata = getMetadata(); |
68 |
} |
69 |
if (inputComponent != null) { |
70 |
remove(inputComponent); |
71 |
inputComponent = null;
|
72 |
} |
73 |
try {
|
74 |
component = ToolsSwingLocator.getDynObjectSwingManager() |
75 |
.createJDynObjectComponent(metadata, this.isEditable());
|
76 |
|
77 |
this.add(inputComponent, BorderLayout.CENTER); |
78 |
} catch (ServiceException e) {
|
79 |
// TODO Auto-generated catch block
|
80 |
e.printStackTrace(); |
81 |
} |
82 |
return this; |
83 |
} |
84 |
|
85 |
protected void initManagers() { |
86 |
manager = MetadataLocator.getMetadataManager(); |
87 |
} |
88 |
|
89 |
public void saveMetadata() throws DynObjectValidateException { |
90 |
try {
|
91 |
this.component.saveStatus();
|
92 |
this.getMetadata().getDynClass().validate(this.getMetadata()); |
93 |
manager.storeMetadata(this.getMetadata());
|
94 |
} catch (MetadataException e) {
|
95 |
e.printStackTrace(); |
96 |
} |
97 |
} |
98 |
|
99 |
protected void initData() { |
100 |
// TODO Auto-generated method stub
|
101 |
|
102 |
} |
103 |
|
104 |
protected void initUI() { |
105 |
// TODO Auto-generated method stub
|
106 |
|
107 |
} |
108 |
|
109 |
} |