50 |
50 |
|
51 |
51 |
import java.awt.BorderLayout;
|
52 |
52 |
import java.awt.Dimension;
|
|
53 |
import java.awt.Window;
|
53 |
54 |
import java.awt.event.ActionEvent;
|
54 |
55 |
import java.awt.event.ActionListener;
|
55 |
56 |
import java.util.List;
|
... | ... | |
68 |
69 |
|
69 |
70 |
import org.gvsig.gui.beans.AcceptCancelPanel;
|
70 |
71 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
|
|
72 |
import org.gvsig.gui.beans.swing.JButton;
|
71 |
73 |
import org.gvsig.topology.ITopologyRule;
|
72 |
74 |
import org.gvsig.topology.ITopologyStatus;
|
73 |
75 |
import org.gvsig.topology.Topology;
|
... | ... | |
93 |
95 |
|
94 |
96 |
private static final long serialVersionUID = 4607286708592192479L;
|
95 |
97 |
|
96 |
|
private Topology workingTopology;
|
|
98 |
// private Topology workingTopology;
|
97 |
99 |
private Topology originalTopology;
|
98 |
100 |
|
99 |
101 |
private JTabbedPane jTabbedPane = null;
|
... | ... | |
103 |
105 |
private TopologyRulesPanel rulesTabPanel = null;
|
104 |
106 |
private TopologyErrorPanel errorPanel = null;
|
105 |
107 |
|
106 |
|
private AcceptCancelPanel acceptCancelPanel = null;
|
|
108 |
private JPanel acceptPanel = null;
|
107 |
109 |
private boolean accepted = false;
|
108 |
110 |
|
|
111 |
private boolean readOnly = true;
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Constructor. It receives the topology whose properties we are going to
|
|
115 |
* show in a tabbed panel.
|
|
116 |
*
|
|
117 |
* @param topology
|
|
118 |
*/
|
109 |
119 |
public TopologyPropertiesPanel(Topology topology){
|
110 |
|
this.originalTopology = topology;
|
111 |
|
this.workingTopology = (Topology) topology.clone();
|
112 |
|
|
|
120 |
this.originalTopology = topology;
|
113 |
121 |
initialize();
|
114 |
122 |
}
|
115 |
123 |
|
... | ... | |
118 |
126 |
this.setSize(523, 385);
|
119 |
127 |
this.setPreferredSize(new Dimension(523, 385));
|
120 |
128 |
this.add(getJTabbedPane(), BorderLayout.CENTER);
|
|
129 |
if(readOnly){
|
|
130 |
this.add(getAcceptPanel(),BorderLayout.SOUTH);
|
|
131 |
}else{
|
|
132 |
this.add(getAcceptCancelPanel(), BorderLayout.SOUTH);
|
|
133 |
}
|
121 |
134 |
this.add(getAcceptCancelPanel(), BorderLayout.SOUTH);
|
122 |
135 |
|
123 |
136 |
final TopologyContentProvider contentProvider =
|
124 |
|
new TopologyContentProvider(workingTopology);
|
|
137 |
new TopologyContentProvider(originalTopology);
|
125 |
138 |
//General tab
|
126 |
|
generalTab = new GeneralTabPanel();
|
|
139 |
generalTab = new GeneralTabPanel(readOnly);
|
127 |
140 |
getJTabbedPane().addTab(PluginServices.getText(this, "General"), generalTab);
|
128 |
141 |
|
129 |
142 |
//Layers tab
|
130 |
|
lyrsPanel = new LayerSelectionPanel(workingTopology.getLayers(), workingTopology.getMapContext());
|
|
143 |
lyrsPanel = new LayerSelectionPanel(originalTopology.getLayers(),
|
|
144 |
originalTopology.getMapContext(), readOnly);
|
|
145 |
|
|
146 |
|
|
147 |
//if panel is read only, we should delete this
|
|
148 |
/*
|
131 |
149 |
lyrsPanel.addLayerSelectionListener(new LayerSelectionListener(){
|
132 |
150 |
public void selectionEvent(SelectedLayerEvent event) {
|
133 |
151 |
FLyrVect eventLyr = (FLyrVect) event.lyrOfEvent;
|
134 |
152 |
String warningMessage = "";
|
135 |
153 |
String title = "";
|
136 |
154 |
if(event.eventType == SelectedLayerEvent.REMOVED_EVENT_TYPE){
|
137 |
|
List<ITopologyRule> rulesToRemove = workingTopology.getRulesByLyr(eventLyr);
|
|
155 |
List<ITopologyRule> rulesToRemove = originalTopology.getRulesByLyr(eventLyr);
|
138 |
156 |
|
139 |
157 |
if(rulesToRemove.size() > 0){
|
140 |
158 |
warningMessage += PluginServices.getText(this, "Remove_Lyr_WARNING1");
|
... | ... | |
152 |
170 |
title);
|
153 |
171 |
|
154 |
172 |
if(deleteLyr)
|
155 |
|
workingTopology.removeLayer(eventLyr);
|
|
173 |
originalTopology.removeLayer(eventLyr);
|
156 |
174 |
}else if(event.eventType == SelectedLayerEvent.ADDED_EVENT_TYPE){
|
157 |
175 |
boolean addLyr = true;
|
158 |
|
if(workingTopology.getStatus() == ITopologyStatus.VALIDATED_WITH_ERRORS){
|
|
176 |
if(originalTopology.getStatus() == ITopologyStatus.VALIDATED_WITH_ERRORS){
|
159 |
177 |
warningMessage = PluginServices.getText(this, "AddLyrDeleteErrors_WARNING");
|
160 |
178 |
title = PluginServices.getText(this, "warning");
|
161 |
179 |
addLyr = GUIUtil.getInstance().optionMessage(warningMessage, title);
|
162 |
180 |
}
|
163 |
181 |
|
164 |
182 |
if(addLyr){
|
165 |
|
workingTopology.addLayer(eventLyr);
|
|
183 |
originalTopology.addLayer(eventLyr);
|
166 |
184 |
errorPanel.updateErrorTable();
|
167 |
185 |
}
|
168 |
186 |
}
|
... | ... | |
170 |
188 |
generalTab.updateContent();
|
171 |
189 |
rulesTabPanel.updateContent(contentProvider);
|
172 |
190 |
}});
|
173 |
|
|
|
191 |
*/
|
174 |
192 |
getJTabbedPane().addTab(PluginServices.getText(this, "Layers"), lyrsPanel);
|
175 |
193 |
|
176 |
194 |
//Rules tab
|
177 |
|
rulesTabPanel = new TopologyRulesPanel(null, contentProvider);
|
|
195 |
rulesTabPanel = new TopologyRulesPanel(null, contentProvider, readOnly);
|
|
196 |
/*
|
178 |
197 |
rulesTabPanel.addRuleSelectionListener(new RuleSelectionListener(){
|
179 |
198 |
public void selectionEvent(SelectedRuleEvent event) {
|
180 |
199 |
ITopologyRule eventRule = event.getRule();
|
181 |
200 |
if(event.getEventType() == SelectedRuleEvent.RULE_REMOVED){
|
182 |
|
workingTopology.removeRule(eventRule);
|
|
201 |
originalTopology.removeRule(eventRule);
|
183 |
202 |
|
184 |
203 |
generalTab.updateContent();
|
185 |
204 |
rulesTabPanel.updateContent(contentProvider);
|
... | ... | |
190 |
209 |
public void selectionEvent(SelectedRuleEvent event) {
|
191 |
210 |
generalTab.updateContent();
|
192 |
211 |
}});
|
|
212 |
*/
|
193 |
213 |
getJTabbedPane().addTab(PluginServices.getText(this, "Rules"), rulesTabPanel);
|
194 |
214 |
|
195 |
215 |
|
196 |
216 |
//Topology errors tab
|
197 |
|
errorPanel = new TopologyErrorPanel(workingTopology.getErrorContainer());
|
|
217 |
errorPanel = new TopologyErrorPanel(originalTopology.getErrorContainer());
|
198 |
218 |
getJTabbedPane().addTab(PluginServices.getText(this, "Errors"), errorPanel);
|
199 |
219 |
}
|
200 |
220 |
|
... | ... | |
206 |
226 |
jTabbedPane.addChangeListener(new ChangeListener() {
|
207 |
227 |
public void stateChanged(ChangeEvent e) {
|
208 |
228 |
JTabbedPane tabs = (JTabbedPane) e.getSource();
|
209 |
|
getAcceptCancelPanel().setOkButtonEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
|
|
229 |
if(acceptPanel instanceof AcceptCancelPanel){
|
|
230 |
((AcceptCancelPanel)acceptPanel).
|
|
231 |
setOkButtonEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
|
|
232 |
}
|
|
233 |
|
210 |
234 |
}
|
211 |
235 |
});
|
212 |
236 |
}
|
213 |
237 |
return jTabbedPane;
|
214 |
238 |
}
|
215 |
239 |
|
216 |
|
private AcceptCancelPanel getAcceptCancelPanel(){
|
217 |
|
if (acceptCancelPanel == null) {
|
|
240 |
// JPanel southPanel = new JPanel();
|
|
241 |
// JButton okButton = new JButton(PluginServices.getText(this, "OK"));
|
|
242 |
//
|
|
243 |
// okButton.addActionListener(new ActionListener() {
|
|
244 |
// public void actionPerformed(ActionEvent arg0) {
|
|
245 |
// Window parentWindow = GUIUtil.getInstance().getParentWindow(
|
|
246 |
// panel);
|
|
247 |
// parentWindow.setVisible(false);
|
|
248 |
// parentWindow.dispose();
|
|
249 |
// panel.setOkPressed(true);
|
|
250 |
// }
|
|
251 |
// });
|
|
252 |
//
|
|
253 |
// southPanel.setLayout(new BorderLayout());
|
|
254 |
// JPanel aux = new JPanel();
|
|
255 |
// aux.add(okButton, BorderLayout.EAST);
|
|
256 |
// southPanel.add(aux, BorderLayout.EAST);
|
|
257 |
// panel.add(southPanel, BorderLayout.SOUTH);
|
|
258 |
|
|
259 |
private JPanel getAcceptPanel(){
|
|
260 |
if(acceptPanel == null){
|
|
261 |
acceptPanel = new JPanel();
|
|
262 |
JButton okButton = new JButton(PluginServices.getText(this, "OK"));
|
|
263 |
|
|
264 |
okButton.addActionListener(new ActionListener() {
|
|
265 |
public void actionPerformed(ActionEvent arg0) {
|
|
266 |
if (PluginServices.getMainFrame() != null) {
|
|
267 |
PluginServices.getMDIManager().closeWindow((IWindow) TopologyPropertiesPanel.this);
|
|
268 |
} else {
|
|
269 |
((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
|
270 |
}
|
|
271 |
}
|
|
272 |
});
|
|
273 |
acceptPanel.setLayout(new BorderLayout());
|
|
274 |
JPanel aux = new JPanel();
|
|
275 |
aux.add(okButton, BorderLayout.EAST);
|
|
276 |
acceptPanel.add(aux, BorderLayout.EAST);
|
|
277 |
}
|
|
278 |
return acceptPanel;
|
|
279 |
}
|
|
280 |
|
|
281 |
private JPanel getAcceptCancelPanel(){
|
|
282 |
if (acceptPanel == null) {
|
218 |
283 |
ActionListener okAction = new ActionListener() {
|
219 |
284 |
public void actionPerformed(ActionEvent e) {
|
220 |
285 |
accepted = true;
|
... | ... | |
241 |
306 |
}
|
242 |
307 |
}
|
243 |
308 |
};
|
244 |
|
acceptCancelPanel = new AcceptCancelPanel(okAction, cancelAction);
|
|
309 |
acceptPanel = new AcceptCancelPanel(okAction, cancelAction);
|
245 |
310 |
}
|
246 |
|
return acceptCancelPanel;
|
|
311 |
return acceptPanel;
|
247 |
312 |
}
|
248 |
313 |
|
249 |
314 |
public boolean isAccepted() {
|
... | ... | |
279 |
344 |
return;
|
280 |
345 |
}
|
281 |
346 |
|
282 |
|
workingTopology.setName(topologyName);
|
|
347 |
originalTopology.setName(topologyName);
|
283 |
348 |
//Meter aqu? un mensaje que avise de que si se cambia la tolerancia de cluster se va a resetear
|
284 |
349 |
//el estado y los errores topologicos
|
285 |
|
workingTopology.setClusterTolerance(clusterTolerance);
|
286 |
|
workingTopology.setMaxNumberOfErrors(maxNumberOfErrors);
|
|
350 |
originalTopology.setClusterTolerance(clusterTolerance);
|
|
351 |
originalTopology.setMaxNumberOfErrors(maxNumberOfErrors);
|
287 |
352 |
}//general tab
|
288 |
353 |
|
289 |
|
try {
|
290 |
|
Topology.copyProperties(workingTopology, originalTopology);
|
291 |
|
} catch (Exception e) {
|
292 |
|
// TODO Auto-generated catch block
|
293 |
|
e.printStackTrace();
|
294 |
|
}
|
|
354 |
// try {
|
|
355 |
// Topology.copyProperties(workingTopology, originalTopology);
|
|
356 |
// } catch (Exception e) {
|
|
357 |
// // TODO Auto-generated catch block
|
|
358 |
// e.printStackTrace();
|
|
359 |
// }
|
295 |
360 |
|
296 |
361 |
GUIUtil.getInstance().updateTopologyInToc(originalTopology.getMapContext(), originalTopology);
|
297 |
362 |
|
... | ... | |
315 |
380 |
JLabel nLyrsLabel;
|
316 |
381 |
JLabel nRulesLabel;
|
317 |
382 |
|
|
383 |
boolean readOnly = false;
|
|
384 |
|
318 |
385 |
boolean changed = false;
|
319 |
386 |
|
320 |
|
public GeneralTabPanel(){
|
|
387 |
public GeneralTabPanel(boolean readOnly){
|
321 |
388 |
super();
|
|
389 |
this.readOnly = readOnly;
|
322 |
390 |
initialize();
|
323 |
391 |
}
|
324 |
392 |
|
... | ... | |
376 |
444 |
JPanel firstPanel = new JPanel();
|
377 |
445 |
firstPanel.setLayout(new BoxLayout(firstPanel, BoxLayout.X_AXIS));
|
378 |
446 |
firstPanel.add(Box.createHorizontalStrut(15));
|
379 |
|
String topologyName = workingTopology.getName();
|
|
447 |
String topologyName = originalTopology.getName();
|
380 |
448 |
firstPanel.add(new JLabel(PluginServices.getText(this, "topology_name")));
|
381 |
449 |
firstPanel.add(Box.createHorizontalStrut(5));
|
382 |
450 |
nameTextField = new JTextField(topologyName, 20);
|
383 |
|
ChangeDocumentListener changeListener = new ChangeDocumentListener();
|
384 |
|
nameTextField.getDocument().addDocumentListener(changeListener);
|
385 |
451 |
firstPanel.add(nameTextField);
|
386 |
452 |
firstPanel.setPreferredSize(new Dimension(500, 20));
|
387 |
453 |
firstPanel.setMinimumSize(new Dimension(500, 20));
|
... | ... | |
394 |
460 |
JPanel secondPanel = new JPanel();
|
395 |
461 |
secondPanel.setLayout(new BoxLayout(secondPanel, BoxLayout.X_AXIS));
|
396 |
462 |
secondPanel.add(Box.createHorizontalStrut(15));
|
397 |
|
double clusterTolerance = workingTopology.getClusterTolerance();
|
|
463 |
double clusterTolerance = originalTopology.getClusterTolerance();
|
398 |
464 |
secondPanel.add(new JLabel(PluginServices.getText(this, "cluster_tolerance")));
|
399 |
465 |
secondPanel.add(Box.createHorizontalStrut(5));
|
400 |
466 |
clusterTextField = new JTextField(Double.toString(clusterTolerance), 20);
|
401 |
467 |
secondPanel.add(clusterTextField);
|
402 |
|
clusterTextField.getDocument().addDocumentListener(changeListener);
|
403 |
468 |
secondPanel.setPreferredSize(new Dimension(500, 20));
|
404 |
469 |
secondPanel.setMinimumSize(new Dimension(500, 20));
|
405 |
470 |
secondPanel.setMaximumSize(new Dimension(500, 20));
|
... | ... | |
423 |
488 |
|
424 |
489 |
add(Box.createVerticalStrut(10));
|
425 |
490 |
JPanel fourthPanel = new JPanel();
|
426 |
|
int maxNumberOfErrors = workingTopology.getMaxNumberOfErrors();
|
|
491 |
int maxNumberOfErrors = originalTopology.getMaxNumberOfErrors();
|
427 |
492 |
fourthPanel.setLayout(new BoxLayout(fourthPanel, BoxLayout.X_AXIS));
|
428 |
493 |
fourthPanel.add(Box.createHorizontalStrut(15));
|
429 |
494 |
fourthPanel.add(new JLabel(PluginServices.getText(this, "max_number_of_errors")));
|
430 |
495 |
fourthPanel.add(Box.createHorizontalStrut(5));
|
431 |
496 |
maxNumberOfErrorsTextField = new JTextField(Integer.toString(maxNumberOfErrors), 20);
|
432 |
|
clusterTextField.getDocument().addDocumentListener(changeListener);
|
433 |
497 |
fourthPanel.add(maxNumberOfErrorsTextField);
|
434 |
498 |
fourthPanel.setPreferredSize(new Dimension(500, 20));
|
435 |
499 |
fourthPanel.setMinimumSize(new Dimension(500, 20));
|
... | ... | |
439 |
503 |
|
440 |
504 |
add(Box.createVerticalStrut(10));
|
441 |
505 |
JPanel fithPanel = new JPanel();
|
442 |
|
int numberOfLyrs = workingTopology.getLayerCount();
|
|
506 |
int numberOfLyrs = originalTopology.getLayerCount();
|
443 |
507 |
fithPanel.setLayout(new BoxLayout(fithPanel, BoxLayout.X_AXIS));
|
444 |
508 |
fithPanel.add(Box.createHorizontalStrut(15));
|
445 |
509 |
fithPanel.add(new JLabel(PluginServices.getText(this, "number_of_layers")));
|
446 |
510 |
fithPanel.add(Box.createHorizontalStrut(5));
|
447 |
511 |
nLyrsLabel = new JLabel("<html><b>"+numberOfLyrs+"</b></html>");
|
448 |
|
|
449 |
512 |
fithPanel.add(nLyrsLabel);
|
450 |
513 |
fithPanel.setPreferredSize(new Dimension(500, 20));
|
451 |
514 |
fithPanel.setMinimumSize(new Dimension(500, 20));
|
... | ... | |
456 |
519 |
|
457 |
520 |
add(Box.createVerticalStrut(10));
|
458 |
521 |
JPanel sixthPanel = new JPanel();
|
459 |
|
int numberOfRules = workingTopology.getAllRules().size();
|
|
522 |
int numberOfRules = originalTopology.getAllRules().size();
|
460 |
523 |
sixthPanel.setLayout(new BoxLayout(sixthPanel, BoxLayout.X_AXIS));
|
461 |
524 |
sixthPanel.add(Box.createHorizontalStrut(15));
|
462 |
525 |
sixthPanel.add(new JLabel(PluginServices.getText(this, "number_of_rules")));
|
... | ... | |
469 |
532 |
sixthPanel.setAlignmentX(LEFT_ALIGNMENT);
|
470 |
533 |
add(sixthPanel);
|
471 |
534 |
add(Box.createVerticalStrut(10));
|
|
535 |
|
|
536 |
//if read only, disable text fields
|
|
537 |
if(readOnly){
|
|
538 |
nameTextField.setEditable(false);
|
|
539 |
clusterTextField.setEditable(false);
|
|
540 |
maxNumberOfErrorsTextField.setEditable(false);
|
|
541 |
}else{
|
|
542 |
ChangeDocumentListener changeListener = new ChangeDocumentListener();
|
|
543 |
nameTextField.getDocument().addDocumentListener(changeListener);
|
|
544 |
clusterTextField.getDocument().addDocumentListener(changeListener);
|
|
545 |
maxNumberOfErrorsTextField.getDocument().addDocumentListener(changeListener);
|
|
546 |
}
|
472 |
547 |
}
|
473 |
548 |
|
474 |
549 |
/**
|
... | ... | |
477 |
552 |
* @return topology status as text
|
478 |
553 |
*/
|
479 |
554 |
private String getStatusAsText() {
|
480 |
|
byte topologyStatus = workingTopology.getStatus();
|
|
555 |
byte topologyStatus = originalTopology.getStatus();
|
481 |
556 |
String topologyText = null;
|
482 |
557 |
switch(topologyStatus){
|
483 |
558 |
case Topology.VALIDATED:
|
... | ... | |
505 |
580 |
|
506 |
581 |
|
507 |
582 |
public void updateContent(){
|
508 |
|
nameTextField.setText(workingTopology.getName());
|
509 |
|
clusterTextField.setText(Double.toString(workingTopology.getClusterTolerance()));
|
|
583 |
nameTextField.setText(originalTopology.getName());
|
|
584 |
clusterTextField.setText(Double.toString(originalTopology.getClusterTolerance()));
|
510 |
585 |
String statusText = getStatusAsText();
|
511 |
586 |
statusLabel.setText("<html><b>"+statusText+"</b></html>");
|
512 |
|
maxNumberOfErrorsTextField.setText(Integer.toString(workingTopology.getMaxNumberOfErrors()));
|
513 |
|
nLyrsLabel.setText("<html><b>"+workingTopology.getLayerCount()+"</b></html>");
|
514 |
|
nRulesLabel.setText(String.valueOf(workingTopology.getRuleCount()));
|
|
587 |
maxNumberOfErrorsTextField.setText(Integer.toString(originalTopology.getMaxNumberOfErrors()));
|
|
588 |
nLyrsLabel.setText("<html><b>"+originalTopology.getLayerCount()+"</b></html>");
|
|
589 |
nRulesLabel.setText(String.valueOf(originalTopology.getRuleCount()));
|
515 |
590 |
}
|
516 |
591 |
}
|
517 |
592 |
|
... | ... | |
542 |
617 |
}
|
543 |
618 |
}
|
544 |
619 |
|
545 |
|
//FIXME Implementar TopologyErrorsPanel (visor alfanumerico de errores topologicos)
|
546 |
|
//y el panel este del TabPanel
|
547 |
|
|
548 |
|
// class TopologyErrorsTabPanel extends JPanel{
|
549 |
|
// void applyChanges(){
|
550 |
|
//
|
551 |
|
// }
|
552 |
|
// }
|
553 |
|
|
554 |
620 |
}
|