Revision 40874
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectEditor.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
import java.awt.BorderLayout; |
35 | 35 |
import java.awt.Component; |
36 |
import java.awt.Dimension; |
|
36 | 37 |
import java.awt.GridBagConstraints; |
37 | 38 |
import java.awt.GridBagLayout; |
38 | 39 |
import java.awt.Insets; |
... | ... | |
43 | 44 |
import javax.swing.JLabel; |
44 | 45 |
import javax.swing.JPanel; |
45 | 46 |
|
46 |
import org.slf4j.Logger; |
|
47 |
import org.slf4j.LoggerFactory; |
|
48 |
|
|
49 | 47 |
import org.gvsig.i18n.Messages; |
48 |
import org.gvsig.tools.dynform.DynFormLocator; |
|
49 |
import org.gvsig.tools.dynform.JDynForm; |
|
50 | 50 |
import org.gvsig.tools.dynobject.DynObject; |
51 | 51 |
import org.gvsig.tools.service.ServiceException; |
52 | 52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
53 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
|
54 | 53 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
55 | 56 |
|
56 | 57 |
/** |
57 | 58 |
* Editor for a store parameters. |
... | ... | |
65 | 66 |
|
66 | 67 |
private static final Logger LOG = LoggerFactory |
67 | 68 |
.getLogger(DynObjectEditor.class); |
68 |
|
|
69 |
private static final WindowManager WINDOW_MANAGER = |
|
70 |
ToolsSwingLocator.getWindowManager(); |
|
71 |
|
|
69 |
|
|
72 | 70 |
private String title; |
73 | 71 |
|
74 | 72 |
private JButton botAcept; |
... | ... | |
76 | 74 |
private JButton botRestoreDefaults; |
77 | 75 |
private JPanel panButtons; |
78 | 76 |
|
79 |
private boolean modal; |
|
77 |
// private boolean modal;
|
|
80 | 78 |
|
81 |
private JDynObjectComponent component; |
|
79 |
private JDynForm form = null; |
|
80 |
private DynObject data = null; |
|
82 | 81 |
|
83 | 82 |
public DynObjectEditor(DynObject parameters, boolean showDefaultsButton) |
84 | 83 |
throws ServiceException { |
85 |
component =
|
|
86 |
ToolsSwingLocator.getDynObjectSwingManager()
|
|
87 |
.createJDynObjectComponent(parameters, true);
|
|
88 |
this.setLayout(new BorderLayout());
|
|
89 |
this.add(component.asJComponent(), BorderLayout.CENTER);
|
|
84 |
this.data = parameters;
|
|
85 |
this.form = DynFormLocator.getDynFormManager().createJDynForm(this.data);
|
|
86 |
this.form.setLayoutMode(this.form.USE_TABS);
|
|
87 |
this.setLayout(new BorderLayout());
|
|
88 |
this.add(this.form.asJComponent(), BorderLayout.CENTER);
|
|
90 | 89 |
this.add(getButtonsPanel(showDefaultsButton), BorderLayout.SOUTH); |
90 |
this.setPreferredSize(new Dimension(500,250)); |
|
91 |
String s = this.data.getDynClass().getDescription(); |
|
92 |
if( s==null || s.length()==0 ) { |
|
93 |
s = this.data.getDynClass().getName(); |
|
94 |
} |
|
95 |
this.setTitle(s); |
|
91 | 96 |
} |
92 | 97 |
|
93 | 98 |
public DynObjectEditor(DynObject parameters) throws ServiceException { |
94 | 99 |
this(parameters, false); |
95 | 100 |
} |
96 | 101 |
|
97 |
|
|
98 | 102 |
private JPanel getButtonsPanel(boolean add_defaults_button) { |
99 | 103 |
if (this.panButtons == null) { |
100 | 104 |
this.panButtons = new JPanel(); |
... | ... | |
163 | 167 |
public void actionPerformed(ActionEvent e) { |
164 | 168 |
Component source = (Component) e.getSource(); |
165 | 169 |
if (source == this.botAcept) { |
166 |
this.component.saveStatus();
|
|
170 |
this.form.getValues(this.data);
|
|
167 | 171 |
this.closeWindow(); |
168 |
|
|
169 |
} else |
|
170 |
if (source == this.botCancel) { |
|
171 |
// TODO Close windows |
|
172 |
this.closeWindow(); |
|
173 |
} else |
|
174 |
if (source == this.botRestoreDefaults) { |
|
175 |
// TODO: implement |
|
176 |
// this.component.restore(); |
|
177 |
|
|
178 |
} |
|
172 |
} else if (source == this.botCancel) { |
|
173 |
this.closeWindow(); |
|
174 |
} else if (source == this.botRestoreDefaults) { |
|
175 |
this.form.setValues(this.data); |
|
176 |
} |
|
179 | 177 |
} |
180 | 178 |
|
181 | 179 |
protected void closeWindow() { |
182 |
LOG.debug("Closing window, values edited: ", component.getDynObject());
|
|
180 |
LOG.debug("Closing window, values edited: ", this.data);
|
|
183 | 181 |
this.setVisible(false); |
184 | 182 |
} |
185 | 183 |
|
186 | 184 |
public void editObject(boolean modal) { |
187 |
this.modal = modal; |
|
185 |
// this.modal = modal;
|
|
188 | 186 |
|
189 |
WINDOW_MANAGER.showWindow(this, |
|
190 |
Messages.getText("explorer_parameters"), |
|
191 |
WindowManager.MODE.DIALOG); |
|
187 |
WindowManager wmanager = ToolsSwingLocator.getWindowManager(); |
|
188 |
|
|
189 |
wmanager.showWindow(this,title,WindowManager.MODE.DIALOG); |
|
190 |
|
|
191 |
// wmanager.showWindow(this, |
|
192 |
// Messages.getText("explorer_parameters"), |
|
193 |
// WindowManager.MODE.DIALOG); |
|
192 | 194 |
} |
193 | 195 |
|
194 | 196 |
public String getTitle() { |
... | ... | |
200 | 202 |
} |
201 | 203 |
|
202 | 204 |
public DynObject getParameters() { |
203 |
return component.getDynObject(); |
|
205 |
this.form.getValues(this.data); |
|
206 |
return this.data; |
|
204 | 207 |
} |
205 | 208 |
} |
Also available in: Unified diff