Revision 35341
branches/v2_0_0_prep/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/UserTableSettingsPanel.java | ||
---|---|---|
64 | 64 |
import org.slf4j.LoggerFactory; |
65 | 65 |
|
66 | 66 |
import org.gvsig.andami.PluginServices; |
67 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor; |
|
68 | 67 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
68 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
|
69 | 69 |
import org.gvsig.gui.beans.swing.JButton; |
70 | 70 |
import org.gvsig.tools.service.ServiceException; |
71 | 71 |
|
branches/v2_0_0_prep/extensions/extGeoDB/src/org/gvsig/geodb/vectorialdb/wizard/VectorialDBConnectionParamsDialog.java | ||
---|---|---|
71 | 71 |
import org.gvsig.fmap.dal.exception.DataException; |
72 | 72 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
73 | 73 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
74 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor;
|
|
74 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
|
|
75 | 75 |
import org.gvsig.tools.service.ServiceException; |
76 | 76 |
|
77 | 77 |
|
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/DynObjectEditor.java | ||
---|---|---|
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 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing; |
|
32 |
|
|
33 |
import java.awt.BorderLayout; |
|
34 |
import java.awt.Component; |
|
35 |
import java.awt.GridBagConstraints; |
|
36 |
import java.awt.GridBagLayout; |
|
37 |
import java.awt.Insets; |
|
38 |
import java.awt.event.ActionEvent; |
|
39 |
import java.awt.event.ActionListener; |
|
40 |
|
|
41 |
import javax.swing.JButton; |
|
42 |
import javax.swing.JFrame; |
|
43 |
import javax.swing.JLabel; |
|
44 |
import javax.swing.JPanel; |
|
45 |
|
|
46 |
import org.slf4j.Logger; |
|
47 |
import org.slf4j.LoggerFactory; |
|
48 |
|
|
49 |
import org.gvsig.andami.PluginServices; |
|
50 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
51 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
52 |
import org.gvsig.tools.dynobject.DynObject; |
|
53 |
import org.gvsig.tools.service.ServiceException; |
|
54 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
55 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
|
56 |
|
|
57 |
/** |
|
58 |
* Editor for a store parameters. |
|
59 |
* |
|
60 |
* @author gvSIG Team |
|
61 |
* @version $Id$ |
|
62 |
*/ |
|
63 |
public class DynObjectEditor extends JPanel implements IWindow, ActionListener { |
|
64 |
|
|
65 |
private static final long serialVersionUID = 23898787077741411L; |
|
66 |
|
|
67 |
private static final Logger LOG = LoggerFactory |
|
68 |
.getLogger(DynObjectEditor.class); |
|
69 |
|
|
70 |
private String title; |
|
71 |
|
|
72 |
private JButton botAcept; |
|
73 |
private JButton botCancel; |
|
74 |
private JButton botRestoreDefaults; |
|
75 |
private JPanel panButtons; |
|
76 |
|
|
77 |
private boolean modal; |
|
78 |
|
|
79 |
private JDynObjectComponent component; |
|
80 |
|
|
81 |
public DynObjectEditor(DynObject parameters) throws ServiceException { |
|
82 |
component = |
|
83 |
ToolsSwingLocator.getDynObjectSwingManager() |
|
84 |
.createJDynObjectComponent(parameters, true); |
|
85 |
this.setLayout(new BorderLayout()); |
|
86 |
this.add(component.asJComponent(), BorderLayout.CENTER); |
|
87 |
this.add(getButtonsPanel(), BorderLayout.SOUTH); |
|
88 |
} |
|
89 |
|
|
90 |
private JPanel getButtonsPanel() { |
|
91 |
if (this.panButtons == null) { |
|
92 |
this.panButtons = new JPanel(); |
|
93 |
this.panButtons.setLayout(new GridBagLayout()); |
|
94 |
GridBagConstraints constr = new GridBagConstraints(); |
|
95 |
constr.anchor = GridBagConstraints.LAST_LINE_END; |
|
96 |
constr.fill = GridBagConstraints.HORIZONTAL; |
|
97 |
constr.weightx = 1; |
|
98 |
constr.weighty = 0; |
|
99 |
this.panButtons.add(new JLabel(), constr); |
|
100 |
|
|
101 |
constr = this.getDefaultParametersConstraints(); |
|
102 |
constr.fill = GridBagConstraints.NONE; |
|
103 |
constr.weightx = 0; |
|
104 |
constr.weighty = 0; |
|
105 |
|
|
106 |
this.panButtons.add(this.getAcceptButton(), constr); |
|
107 |
this.panButtons.add(this.getCancelButton(), constr); |
|
108 |
this.panButtons.add(this.getRestoreDefaults(), constr); |
|
109 |
} |
|
110 |
return this.panButtons; |
|
111 |
} |
|
112 |
|
|
113 |
private GridBagConstraints getDefaultParametersConstraints() { |
|
114 |
GridBagConstraints constr = new GridBagConstraints(); |
|
115 |
constr.insets = new Insets(2, 2, 2, 2); |
|
116 |
constr.ipadx = 2; |
|
117 |
constr.ipady = 2; |
|
118 |
constr.anchor = GridBagConstraints.PAGE_START; |
|
119 |
return constr; |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
private JButton getRestoreDefaults() { |
|
124 |
if (this.botRestoreDefaults == null) { |
|
125 |
this.botRestoreDefaults = |
|
126 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
127 |
PluginServices.getText(this, "restoreDefaults")); |
|
128 |
this.botRestoreDefaults.addActionListener(this); |
|
129 |
} |
|
130 |
return this.botRestoreDefaults; |
|
131 |
} |
|
132 |
|
|
133 |
private JButton getCancelButton() { |
|
134 |
if (this.botCancel == null) { |
|
135 |
this.botCancel = |
|
136 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
137 |
PluginServices.getText(this, "cancel")); |
|
138 |
this.botCancel.addActionListener(this); |
|
139 |
} |
|
140 |
return this.botCancel; |
|
141 |
} |
|
142 |
|
|
143 |
private JButton getAcceptButton() { |
|
144 |
if (this.botAcept == null) { |
|
145 |
this.botAcept = |
|
146 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
147 |
PluginServices.getText(this, "accept")); |
|
148 |
this.botAcept.addActionListener(this); |
|
149 |
} |
|
150 |
return this.botAcept; |
|
151 |
} |
|
152 |
|
|
153 |
public void actionPerformed(ActionEvent e) { |
|
154 |
Component source = (Component) e.getSource(); |
|
155 |
if (source == this.botAcept) { |
|
156 |
this.component.saveStatus(); |
|
157 |
this.closeWindow(); |
|
158 |
|
|
159 |
} else |
|
160 |
if (source == this.botCancel) { |
|
161 |
// TODO Close windows |
|
162 |
this.closeWindow(); |
|
163 |
} else |
|
164 |
if (source == this.botRestoreDefaults) { |
|
165 |
// TODO: implement |
|
166 |
// this.component.restore(); |
|
167 |
|
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
protected void closeWindow() { |
|
172 |
LOG.debug("Closing window, values edited: ", component.getDynObject()); |
|
173 |
if (PluginServices.getMainFrame() == null) { |
|
174 |
((JFrame) (getParent().getParent().getParent().getParent())) |
|
175 |
.dispose(); |
|
176 |
} else { |
|
177 |
PluginServices.getMDIManager().closeWindow(this); |
|
178 |
} |
|
179 |
} |
|
180 |
|
|
181 |
/* |
|
182 |
* (non-Javadoc) |
|
183 |
* |
|
184 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
185 |
*/ |
|
186 |
public WindowInfo getWindowInfo() { |
|
187 |
WindowInfo m_viewinfo; |
|
188 |
if (this.modal) { |
|
189 |
m_viewinfo = |
|
190 |
new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
191 |
} else { |
|
192 |
m_viewinfo = new WindowInfo(WindowInfo.RESIZABLE); |
|
193 |
} |
|
194 |
m_viewinfo.setTitle(this.title); |
|
195 |
m_viewinfo.setHeight(500); |
|
196 |
m_viewinfo.setWidth(520); |
|
197 |
return m_viewinfo; |
|
198 |
} |
|
199 |
|
|
200 |
public void editObject(boolean modal) { |
|
201 |
this.modal = modal; |
|
202 |
try { |
|
203 |
PluginServices.getMDIManager().addWindow(this); |
|
204 |
} catch (Exception e) { |
|
205 |
JFrame frame = new JFrame(); |
|
206 |
frame.setLayout(new BorderLayout()); |
|
207 |
frame.add(this); |
|
208 |
frame.setBounds(10, 10, 400, 400); |
|
209 |
frame.setVisible(true); |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
public String getTitle() { |
|
214 |
return title; |
|
215 |
} |
|
216 |
|
|
217 |
public void setTitle(String title) { |
|
218 |
this.title = title; |
|
219 |
} |
|
220 |
|
|
221 |
public Object getWindowProfile() { |
|
222 |
return WindowInfo.PROPERTIES_PROFILE; |
|
223 |
} |
|
224 |
|
|
225 |
public DynObject getParameters() { |
|
226 |
return component.getDynObject(); |
|
227 |
} |
|
228 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/DynObjectViewer.java | ||
---|---|---|
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 |
* 2009 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing; |
|
29 |
|
|
30 |
import java.awt.Color; |
|
31 |
import java.awt.GridBagConstraints; |
|
32 |
import java.awt.GridBagLayout; |
|
33 |
|
|
34 |
import javax.swing.JLabel; |
|
35 |
import javax.swing.JPanel; |
|
36 |
import javax.swing.JTextField; |
|
37 |
|
|
38 |
import org.cresques.cts.IProjection; |
|
39 |
import org.gvsig.andami.PluginServices; |
|
40 |
import org.gvsig.tools.dynobject.DynClass; |
|
41 |
import org.gvsig.tools.dynobject.DynField; |
|
42 |
import org.gvsig.tools.dynobject.DynObject; |
|
43 |
|
|
44 |
|
|
45 |
public class DynObjectViewer extends JPanel { |
|
46 |
|
|
47 |
/** |
|
48 |
* |
|
49 |
*/ |
|
50 |
private static final long serialVersionUID = -5277036770491043233L; |
|
51 |
private GridBagConstraints paramsListLabelConstraint; |
|
52 |
private GridBagConstraints paramsListValueConstraint; |
|
53 |
private GridBagConstraints paramsListFillConstraint; |
|
54 |
|
|
55 |
public DynObjectViewer() { |
|
56 |
super(); |
|
57 |
this.intialize(); |
|
58 |
} |
|
59 |
|
|
60 |
private void intialize() { |
|
61 |
this.setLayout(new GridBagLayout()); |
|
62 |
|
|
63 |
paramsListLabelConstraint = new GridBagConstraints(); |
|
64 |
paramsListValueConstraint = new GridBagConstraints(); |
|
65 |
paramsListFillConstraint = new GridBagConstraints(); |
|
66 |
|
|
67 |
paramsListLabelConstraint.ipadx = 3; |
|
68 |
paramsListLabelConstraint.ipady = 3; |
|
69 |
paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START; |
|
70 |
paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE; |
|
71 |
paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
72 |
|
|
73 |
paramsListValueConstraint.ipadx = 3; |
|
74 |
paramsListValueConstraint.ipady = 3; |
|
75 |
paramsListValueConstraint.anchor = GridBagConstraints.FIRST_LINE_END; |
|
76 |
paramsListValueConstraint.gridwidth = GridBagConstraints.REMAINDER; |
|
77 |
paramsListValueConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
78 |
paramsListValueConstraint.weightx = 1; |
|
79 |
|
|
80 |
paramsListFillConstraint.ipadx = 3; |
|
81 |
paramsListFillConstraint.ipady = 3; |
|
82 |
paramsListFillConstraint.anchor = GridBagConstraints.FIRST_LINE_END; |
|
83 |
paramsListFillConstraint.gridwidth = GridBagConstraints.REMAINDER; |
|
84 |
paramsListFillConstraint.fill = GridBagConstraints.BOTH; |
|
85 |
paramsListFillConstraint.weightx = 1; |
|
86 |
paramsListFillConstraint.weighty = 1; |
|
87 |
} |
|
88 |
|
|
89 |
private String getLocalizedText(String txt) { |
|
90 |
try { |
|
91 |
return PluginServices.getText(this, txt); |
|
92 |
} catch (Exception e) { |
|
93 |
return txt; |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
public void load(DynObject dynObj) { |
|
98 |
this.removeAll(); |
|
99 |
|
|
100 |
if (dynObj == null) { |
|
101 |
this.doLayout(); |
|
102 |
return; |
|
103 |
} |
|
104 |
DynClass dynClass = dynObj.getDynClass(); |
|
105 |
|
|
106 |
JTextField label; |
|
107 |
JTextField text; |
|
108 |
Object value; |
|
109 |
String strValue; |
|
110 |
|
|
111 |
// label = new JLabel(); |
|
112 |
// label.setText(getLocalizedText("parameter")); |
|
113 |
// label.setBackground(Color.LIGHT_GRAY); |
|
114 |
// this.add(label, paramsListLabelConstraint); |
|
115 |
|
|
116 |
text = new JTextField(); |
|
117 |
text.setText(getLocalizedText("parameter")); |
|
118 |
text.setEditable(false); |
|
119 |
text.setBackground(Color.LIGHT_GRAY); |
|
120 |
this.add(text, paramsListLabelConstraint); |
|
121 |
|
|
122 |
text = new JTextField(); |
|
123 |
text.setText(getLocalizedText("value")); |
|
124 |
text.setEditable(false); |
|
125 |
text.setBackground(Color.LIGHT_GRAY); |
|
126 |
this.add(text, paramsListValueConstraint); |
|
127 |
|
|
128 |
for (DynField field : dynClass.getDynFields()) { |
|
129 |
label = new JTextField(); |
|
130 |
label.setText(field.getDescription()); |
|
131 |
label.setEditable(false); |
|
132 |
this.add(label, paramsListLabelConstraint); |
|
133 |
|
|
134 |
strValue = ""; |
|
135 |
value = dynObj.getDynValue(field.getName()); |
|
136 |
if (value != null) { |
|
137 |
if (value instanceof String) { |
|
138 |
strValue = (String) value; |
|
139 |
} else if (value instanceof IProjection) { |
|
140 |
strValue = ((IProjection) value).getAbrev(); |
|
141 |
} else { |
|
142 |
strValue = value.toString(); |
|
143 |
} |
|
144 |
|
|
145 |
} |
|
146 |
text = new JTextField(); |
|
147 |
text.setText(strValue); |
|
148 |
text.setEditable(false); |
|
149 |
this.add(text, paramsListValueConstraint); |
|
150 |
} |
|
151 |
|
|
152 |
this.add(new JLabel(), paramsListFillConstraint); |
|
153 |
|
|
154 |
this.doLayout(); |
|
155 |
this.repaint(); |
|
156 |
|
|
157 |
} |
|
158 |
} |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerWizardPanel.java | ||
---|---|---|
69 | 69 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
70 | 70 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
71 | 71 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
72 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
|
73 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectViewer; |
|
72 | 74 |
import org.gvsig.gui.beans.swing.JButton; |
73 | 75 |
import org.gvsig.gui.beans.swing.JFileChooser; |
74 | 76 |
import org.gvsig.tools.dynobject.DynObject; |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerAddLayerWizardPanel.java | ||
---|---|---|
47 | 47 |
import org.gvsig.fmap.dal.DataTypes; |
48 | 48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
49 | 49 |
import org.gvsig.fmap.mapcontrol.MapControl; |
50 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
|
50 | 51 |
import org.gvsig.tools.dynobject.DynField; |
51 | 52 |
import org.gvsig.tools.dynobject.DynObject; |
52 | 53 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java | ||
---|---|---|
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 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.mapcontrol.swing.dynobject; |
|
32 |
|
|
33 |
import java.awt.BorderLayout; |
|
34 |
import java.awt.Component; |
|
35 |
import java.awt.GridBagConstraints; |
|
36 |
import java.awt.GridBagLayout; |
|
37 |
import java.awt.Insets; |
|
38 |
import java.awt.event.ActionEvent; |
|
39 |
import java.awt.event.ActionListener; |
|
40 |
|
|
41 |
import javax.swing.JButton; |
|
42 |
import javax.swing.JLabel; |
|
43 |
import javax.swing.JPanel; |
|
44 |
|
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 |
import org.gvsig.i18n.Messages; |
|
49 |
import org.gvsig.tools.dynobject.DynObject; |
|
50 |
import org.gvsig.tools.service.ServiceException; |
|
51 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
52 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
|
53 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
54 |
|
|
55 |
/** |
|
56 |
* Editor for a store parameters. |
|
57 |
* |
|
58 |
* @author gvSIG Team |
|
59 |
* @version $Id$ |
|
60 |
*/ |
|
61 |
public class DynObjectEditor extends JPanel implements ActionListener { |
|
62 |
|
|
63 |
private static final long serialVersionUID = 23898787077741411L; |
|
64 |
|
|
65 |
private static final Logger LOG = LoggerFactory |
|
66 |
.getLogger(DynObjectEditor.class); |
|
67 |
|
|
68 |
private static final WindowManager WINDOW_MANAGER = |
|
69 |
ToolsSwingLocator.getWindowManager(); |
|
70 |
|
|
71 |
private String title; |
|
72 |
|
|
73 |
private JButton botAcept; |
|
74 |
private JButton botCancel; |
|
75 |
private JButton botRestoreDefaults; |
|
76 |
private JPanel panButtons; |
|
77 |
|
|
78 |
private boolean modal; |
|
79 |
|
|
80 |
private JDynObjectComponent component; |
|
81 |
|
|
82 |
public DynObjectEditor(DynObject parameters) throws ServiceException { |
|
83 |
component = |
|
84 |
ToolsSwingLocator.getDynObjectSwingManager() |
|
85 |
.createJDynObjectComponent(parameters, true); |
|
86 |
this.setLayout(new BorderLayout()); |
|
87 |
this.add(component.asJComponent(), BorderLayout.CENTER); |
|
88 |
this.add(getButtonsPanel(), BorderLayout.SOUTH); |
|
89 |
} |
|
90 |
|
|
91 |
private JPanel getButtonsPanel() { |
|
92 |
if (this.panButtons == null) { |
|
93 |
this.panButtons = new JPanel(); |
|
94 |
this.panButtons.setLayout(new GridBagLayout()); |
|
95 |
GridBagConstraints constr = new GridBagConstraints(); |
|
96 |
constr.anchor = GridBagConstraints.LAST_LINE_END; |
|
97 |
constr.fill = GridBagConstraints.HORIZONTAL; |
|
98 |
constr.weightx = 1; |
|
99 |
constr.weighty = 0; |
|
100 |
this.panButtons.add(new JLabel(), constr); |
|
101 |
|
|
102 |
constr = this.getDefaultParametersConstraints(); |
|
103 |
constr.fill = GridBagConstraints.NONE; |
|
104 |
constr.weightx = 0; |
|
105 |
constr.weighty = 0; |
|
106 |
|
|
107 |
this.panButtons.add(this.getAcceptButton(), constr); |
|
108 |
this.panButtons.add(this.getCancelButton(), constr); |
|
109 |
this.panButtons.add(this.getRestoreDefaults(), constr); |
|
110 |
} |
|
111 |
return this.panButtons; |
|
112 |
} |
|
113 |
|
|
114 |
private GridBagConstraints getDefaultParametersConstraints() { |
|
115 |
GridBagConstraints constr = new GridBagConstraints(); |
|
116 |
constr.insets = new Insets(2, 2, 2, 2); |
|
117 |
constr.ipadx = 2; |
|
118 |
constr.ipady = 2; |
|
119 |
constr.anchor = GridBagConstraints.PAGE_START; |
|
120 |
return constr; |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
private JButton getRestoreDefaults() { |
|
125 |
if (this.botRestoreDefaults == null) { |
|
126 |
this.botRestoreDefaults = |
|
127 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
128 |
Messages.getText("restoreDefaults")); |
|
129 |
this.botRestoreDefaults.addActionListener(this); |
|
130 |
} |
|
131 |
return this.botRestoreDefaults; |
|
132 |
} |
|
133 |
|
|
134 |
private JButton getCancelButton() { |
|
135 |
if (this.botCancel == null) { |
|
136 |
this.botCancel = |
|
137 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
138 |
Messages.getText("cancel")); |
|
139 |
this.botCancel.addActionListener(this); |
|
140 |
} |
|
141 |
return this.botCancel; |
|
142 |
} |
|
143 |
|
|
144 |
private JButton getAcceptButton() { |
|
145 |
if (this.botAcept == null) { |
|
146 |
this.botAcept = |
|
147 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
|
148 |
Messages.getText("accept")); |
|
149 |
this.botAcept.addActionListener(this); |
|
150 |
} |
|
151 |
return this.botAcept; |
|
152 |
} |
|
153 |
|
|
154 |
public void actionPerformed(ActionEvent e) { |
|
155 |
Component source = (Component) e.getSource(); |
|
156 |
if (source == this.botAcept) { |
|
157 |
this.component.saveStatus(); |
|
158 |
this.closeWindow(); |
|
159 |
|
|
160 |
} else |
|
161 |
if (source == this.botCancel) { |
|
162 |
// TODO Close windows |
|
163 |
this.closeWindow(); |
|
164 |
} else |
|
165 |
if (source == this.botRestoreDefaults) { |
|
166 |
// TODO: implement |
|
167 |
// this.component.restore(); |
|
168 |
|
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
protected void closeWindow() { |
|
173 |
LOG.debug("Closing window, values edited: ", component.getDynObject()); |
|
174 |
this.setVisible(false); |
|
175 |
} |
|
176 |
|
|
177 |
public void editObject(boolean modal) { |
|
178 |
this.modal = modal; |
|
179 |
|
|
180 |
WINDOW_MANAGER.showWindow(this, |
|
181 |
Messages.getText("explorer_parameters"), |
|
182 |
WindowManager.MODE.DIALOG); |
|
183 |
} |
|
184 |
|
|
185 |
public String getTitle() { |
|
186 |
return title; |
|
187 |
} |
|
188 |
|
|
189 |
public void setTitle(String title) { |
|
190 |
this.title = title; |
|
191 |
} |
|
192 |
|
|
193 |
public DynObject getParameters() { |
|
194 |
return component.getDynObject(); |
|
195 |
} |
|
196 |
} |
|
0 | 197 |
branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java | ||
---|---|---|
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 |
* 2009 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.mapcontrol.swing.dynobject; |
|
29 |
|
|
30 |
import java.awt.Color; |
|
31 |
import java.awt.GridBagConstraints; |
|
32 |
import java.awt.GridBagLayout; |
|
33 |
|
|
34 |
import javax.swing.JLabel; |
|
35 |
import javax.swing.JPanel; |
|
36 |
import javax.swing.JTextField; |
|
37 |
|
|
38 |
import org.cresques.cts.IProjection; |
|
39 |
|
|
40 |
import org.gvsig.i18n.Messages; |
|
41 |
import org.gvsig.tools.dynobject.DynClass; |
|
42 |
import org.gvsig.tools.dynobject.DynField; |
|
43 |
import org.gvsig.tools.dynobject.DynObject; |
|
44 |
|
|
45 |
|
|
46 |
public class DynObjectViewer extends JPanel { |
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
*/ |
|
51 |
private static final long serialVersionUID = -5277036770491043233L; |
|
52 |
private GridBagConstraints paramsListLabelConstraint; |
|
53 |
private GridBagConstraints paramsListValueConstraint; |
|
54 |
private GridBagConstraints paramsListFillConstraint; |
|
55 |
|
|
56 |
public DynObjectViewer() { |
|
57 |
super(); |
|
58 |
this.intialize(); |
|
59 |
} |
|
60 |
|
|
61 |
private void intialize() { |
|
62 |
this.setLayout(new GridBagLayout()); |
|
63 |
|
|
64 |
paramsListLabelConstraint = new GridBagConstraints(); |
|
65 |
paramsListValueConstraint = new GridBagConstraints(); |
|
66 |
paramsListFillConstraint = new GridBagConstraints(); |
|
67 |
|
|
68 |
paramsListLabelConstraint.ipadx = 3; |
|
69 |
paramsListLabelConstraint.ipady = 3; |
|
70 |
paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START; |
|
71 |
paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE; |
|
72 |
paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
73 |
|
|
74 |
paramsListValueConstraint.ipadx = 3; |
|
75 |
paramsListValueConstraint.ipady = 3; |
|
76 |
paramsListValueConstraint.anchor = GridBagConstraints.FIRST_LINE_END; |
|
77 |
paramsListValueConstraint.gridwidth = GridBagConstraints.REMAINDER; |
|
78 |
paramsListValueConstraint.fill = GridBagConstraints.HORIZONTAL; |
|
79 |
paramsListValueConstraint.weightx = 1; |
|
80 |
|
|
81 |
paramsListFillConstraint.ipadx = 3; |
|
82 |
paramsListFillConstraint.ipady = 3; |
|
83 |
paramsListFillConstraint.anchor = GridBagConstraints.FIRST_LINE_END; |
|
84 |
paramsListFillConstraint.gridwidth = GridBagConstraints.REMAINDER; |
|
85 |
paramsListFillConstraint.fill = GridBagConstraints.BOTH; |
|
86 |
paramsListFillConstraint.weightx = 1; |
|
87 |
paramsListFillConstraint.weighty = 1; |
|
88 |
} |
|
89 |
|
|
90 |
private String getLocalizedText(String txt) { |
|
91 |
try { |
|
92 |
return Messages.getText(txt); |
|
93 |
} catch (Exception e) { |
|
94 |
return txt; |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
public void load(DynObject dynObj) { |
|
99 |
this.removeAll(); |
|
100 |
|
|
101 |
if (dynObj == null) { |
|
102 |
this.doLayout(); |
|
103 |
return; |
|
104 |
} |
|
105 |
DynClass dynClass = dynObj.getDynClass(); |
|
106 |
|
|
107 |
JTextField label; |
|
108 |
JTextField text; |
|
109 |
Object value; |
|
110 |
String strValue; |
|
111 |
|
|
112 |
// label = new JLabel(); |
|
113 |
// label.setText(getLocalizedText("parameter")); |
|
114 |
// label.setBackground(Color.LIGHT_GRAY); |
|
115 |
// this.add(label, paramsListLabelConstraint); |
|
116 |
|
|
117 |
text = new JTextField(); |
|
118 |
text.setText(getLocalizedText("parameter")); |
|
119 |
text.setEditable(false); |
|
120 |
text.setBackground(Color.LIGHT_GRAY); |
|
121 |
this.add(text, paramsListLabelConstraint); |
|
122 |
|
|
123 |
text = new JTextField(); |
|
124 |
text.setText(getLocalizedText("value")); |
|
125 |
text.setEditable(false); |
|
126 |
text.setBackground(Color.LIGHT_GRAY); |
|
127 |
this.add(text, paramsListValueConstraint); |
|
128 |
|
|
129 |
for (DynField field : dynClass.getDynFields()) { |
|
130 |
label = new JTextField(); |
|
131 |
label.setText(field.getDescription()); |
|
132 |
label.setEditable(false); |
|
133 |
this.add(label, paramsListLabelConstraint); |
|
134 |
|
|
135 |
strValue = ""; |
|
136 |
value = dynObj.getDynValue(field.getName()); |
|
137 |
if (value != null) { |
|
138 |
if (value instanceof String) { |
|
139 |
strValue = (String) value; |
|
140 |
} else if (value instanceof IProjection) { |
|
141 |
strValue = ((IProjection) value).getAbrev(); |
|
142 |
} else { |
|
143 |
strValue = value.toString(); |
|
144 |
} |
|
145 |
|
|
146 |
} |
|
147 |
text = new JTextField(); |
|
148 |
text.setText(strValue); |
|
149 |
text.setEditable(false); |
|
150 |
this.add(text, paramsListValueConstraint); |
|
151 |
} |
|
152 |
|
|
153 |
this.add(new JLabel(), paramsListFillConstraint); |
|
154 |
|
|
155 |
this.doLayout(); |
|
156 |
this.repaint(); |
|
157 |
|
|
158 |
} |
|
159 |
} |
|
0 | 160 |
branches/v2_0_0_prep/libraries/libFMap_controls/pom.xml | ||
---|---|---|
133 | 133 |
<artifactId>jts</artifactId> |
134 | 134 |
<scope>compile</scope> |
135 | 135 |
</dependency> |
136 |
<dependency> |
|
137 |
<groupId>org.gvsig</groupId> |
|
138 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
139 |
<scope>compile</scope> |
|
140 |
</dependency> |
|
136 | 141 |
<!-- TODO: uncomment when mapcontexts tests work again |
137 | 142 |
<dependency> |
138 | 143 |
<groupId>org.gvsig</groupId> |
Also available in: Unified diff