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 @ 40769
History | View | Annotate | Download (3.17 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.metadata.swing.basic.impl; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
|
28 |
import javax.swing.JComponent; |
29 |
|
30 |
import org.gvsig.metadata.Metadata; |
31 |
import org.gvsig.metadata.MetadataLocator; |
32 |
import org.gvsig.metadata.MetadataManager; |
33 |
import org.gvsig.metadata.exceptions.MetadataException; |
34 |
import org.gvsig.metadata.swing.basic.api.AbstractSimpleMetadataPanel; |
35 |
import org.gvsig.metadata.swing.basic.api.JMetadataPanel; |
36 |
import org.gvsig.metadata.swing.basic.api.MetadataSwingManager; |
37 |
import org.gvsig.tools.dynobject.exception.DynObjectValidateException; |
38 |
import org.gvsig.tools.service.ServiceException; |
39 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
40 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
41 |
|
42 |
public class JMetadataEditorPanel extends JMetadataPanel { |
43 |
|
44 |
/**
|
45 |
*
|
46 |
*/
|
47 |
private static final long serialVersionUID = -5680452321763343711L; |
48 |
private JDynObjectComponent component;
|
49 |
private JComponent inputComponent; |
50 |
private MetadataManager manager;
|
51 |
|
52 |
public JMetadataEditorPanel(MetadataSwingManager uiManager,
|
53 |
Metadata metadata, boolean isEditable) {
|
54 |
super(uiManager, metadata, isEditable);
|
55 |
} |
56 |
|
57 |
protected AbstractSimpleMetadataPanel createMetadataComponent(
|
58 |
Metadata metadata, boolean doRefresh) {
|
59 |
if (metadata == null) { |
60 |
metadata = getMetadata(); |
61 |
} |
62 |
if (inputComponent != null) { |
63 |
remove(inputComponent); |
64 |
inputComponent = null;
|
65 |
} |
66 |
try {
|
67 |
component = ToolsSwingLocator.getDynObjectSwingManager() |
68 |
.createJDynObjectComponent(metadata, this.isEditable());
|
69 |
|
70 |
this.add(inputComponent, BorderLayout.CENTER); |
71 |
} catch (ServiceException e) {
|
72 |
// TODO Auto-generated catch block
|
73 |
e.printStackTrace(); |
74 |
} |
75 |
return this; |
76 |
} |
77 |
|
78 |
protected void initManagers() { |
79 |
manager = MetadataLocator.getMetadataManager(); |
80 |
} |
81 |
|
82 |
public void saveMetadata() throws DynObjectValidateException { |
83 |
try {
|
84 |
this.component.saveStatus();
|
85 |
this.getMetadata().getDynClass().validate(this.getMetadata()); |
86 |
manager.storeMetadata(this.getMetadata());
|
87 |
} catch (MetadataException e) {
|
88 |
e.printStackTrace(); |
89 |
} |
90 |
} |
91 |
|
92 |
protected void initData() { |
93 |
// TODO Auto-generated method stub
|
94 |
|
95 |
} |
96 |
|
97 |
protected void initUI() { |
98 |
// TODO Auto-generated method stub
|
99 |
|
100 |
} |
101 |
|
102 |
} |