gvsig-educa / org.gvsig.educa.portableview / trunk / org.gvsig.educa.portableview / org.gvsig.educa.portableview.swing / org.gvsig.educa.portableview.swing.impl / src / main / java / org / gvsig / educa / portableview / swing / impl / editor / addlayer / StoreParametersEditor.java @ 302
History | View | Annotate | Download (4.18 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 |
package org.gvsig.educa.portableview.swing.impl.editor.addlayer; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.event.ActionEvent; |
26 |
import java.awt.event.ActionListener; |
27 |
|
28 |
import javax.swing.Box; |
29 |
import javax.swing.BoxLayout; |
30 |
import javax.swing.JButton; |
31 |
import javax.swing.JPanel; |
32 |
|
33 |
import org.gvsig.educa.portableview.swing.PortableViewSwingLocator; |
34 |
import org.gvsig.educa.portableview.swing.PortableViewSwingManager; |
35 |
import org.gvsig.fmap.dal.DataStoreParameters; |
36 |
import org.gvsig.tools.dynform.DynFormLocator; |
37 |
import org.gvsig.tools.dynform.DynFormManager; |
38 |
import org.gvsig.tools.dynform.JDynForm; |
39 |
import org.gvsig.tools.exception.BaseException; |
40 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
41 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
42 |
|
43 |
/**
|
44 |
* <p>
|
45 |
* Dialog to edit Data Store parameters (used by
|
46 |
* {@link StoreParametersCellEditor})
|
47 |
* </p>
|
48 |
* <p>
|
49 |
* Uses {@link DynObjectSwingManager} to generate components
|
50 |
* </p>
|
51 |
*
|
52 |
* @author gvSIG Team
|
53 |
* @version $Id$
|
54 |
*
|
55 |
*/
|
56 |
public class StoreParametersEditor extends JPanel implements ActionListener { |
57 |
|
58 |
/**
|
59 |
*
|
60 |
*/
|
61 |
private static final long serialVersionUID = -3044289357512879309L; |
62 |
|
63 |
private final PortableViewSwingManager swingManager; |
64 |
private final UsabilitySwingManager usabManager; |
65 |
|
66 |
private final DynFormManager dynSwingManager; |
67 |
private JDynForm propertyEditor;
|
68 |
private DataStoreParameters parameters;
|
69 |
|
70 |
private JButton botAccept; |
71 |
|
72 |
private JButton botCancel; |
73 |
|
74 |
/**
|
75 |
*
|
76 |
*/
|
77 |
public StoreParametersEditor(DataStoreParameters parameters) {
|
78 |
super();
|
79 |
dynSwingManager = DynFormLocator.getDynFormManager(); |
80 |
swingManager = PortableViewSwingLocator.getSwingManager(); |
81 |
usabManager = ToolsSwingLocator.getUsabilitySwingManager(); |
82 |
|
83 |
// create property editor component
|
84 |
try {
|
85 |
this.parameters = parameters;
|
86 |
propertyEditor = dynSwingManager.createJDynForm(parameters); |
87 |
} catch (BaseException ex) {
|
88 |
// TODO
|
89 |
return;
|
90 |
} |
91 |
setLayout(new BorderLayout(10, 10)); |
92 |
add(propertyEditor.asJComponent(), BorderLayout.CENTER);
|
93 |
|
94 |
// Create panel for commands
|
95 |
JPanel commandsPanel = new JPanel(); |
96 |
commandsPanel.setLayout(new BoxLayout(commandsPanel, BoxLayout.X_AXIS)); |
97 |
commandsPanel.add(Box.createHorizontalGlue());
|
98 |
botAccept = |
99 |
usabManager.createJButton(swingManager.getTranslation("accept"));
|
100 |
botAccept.addActionListener(this);
|
101 |
|
102 |
botCancel = |
103 |
usabManager.createJButton(swingManager.getTranslation("cancel"));
|
104 |
botCancel.addActionListener(this);
|
105 |
|
106 |
commandsPanel.add(botAccept); |
107 |
commandsPanel.add(Box.createHorizontalStrut(10)); |
108 |
commandsPanel.add(botCancel); |
109 |
commandsPanel.add(Box.createHorizontalStrut(5)); |
110 |
add(commandsPanel, BorderLayout.SOUTH);
|
111 |
} |
112 |
|
113 |
public void actionPerformed(ActionEvent e) { |
114 |
Object source = e.getSource();
|
115 |
if (source == botCancel) {
|
116 |
close(); |
117 |
return;
|
118 |
} |
119 |
if (source == botAccept) {
|
120 |
propertyEditor.getValues(parameters); |
121 |
// TODO validate... but before solve CRS problem
|
122 |
close(); |
123 |
return;
|
124 |
} |
125 |
} |
126 |
|
127 |
/**
|
128 |
* close dialog
|
129 |
*/
|
130 |
private void close() { |
131 |
setVisible(false);
|
132 |
} |
133 |
} |