Revision 341 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/gui/dialogs/FFrameViewDialog.java
FFrameViewDialog.java | ||
---|---|---|
56 | 56 |
import org.gvsig.app.project.documents.layout.fframes.gui.EnvelopePanel; |
57 | 57 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
58 | 58 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
59 |
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
|
59 | 60 |
import org.gvsig.app.project.documents.view.DefaultViewDocument; |
60 | 61 |
import org.gvsig.app.project.documents.view.ViewDocument; |
62 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
61 | 63 |
import org.gvsig.fmap.geom.primitive.Envelope; |
62 | 64 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
63 | 65 |
import org.gvsig.i18n.Messages; |
... | ... | |
84 | 86 |
private javax.swing.JButton bCancelar = null; |
85 | 87 |
private javax.swing.JLabel lCalidad = null; |
86 | 88 |
private javax.swing.JComboBox cbCalidad = null; |
87 |
private DefaultViewDocument m_projectView = null;
|
|
89 |
private ViewDocument m_projectView = null; |
|
88 | 90 |
private Rectangle2D rect = new Rectangle2D.Double(); |
89 | 91 |
private FFrameView fframeview = null; |
90 | 92 |
private boolean isAcepted = false; |
... | ... | |
107 | 109 |
private EnvelopePanel pnlExtent = null; |
108 | 110 |
private JButton btConfigView = null; |
109 | 111 |
private JPanel pnlScale = null; |
112 |
private ViewDocument createdView = null; |
|
110 | 113 |
|
111 | 114 |
|
112 | 115 |
/** |
... | ... | |
241 | 244 |
} |
242 | 245 |
return pnlFirstRow; |
243 | 246 |
} |
247 |
|
|
244 | 248 |
|
245 |
protected ViewDocument getSelectedView() { |
|
246 |
Object selected = getViewList().getSelectedValue(); |
|
247 |
if (selected instanceof ViewDocument) { |
|
248 |
return (ViewDocument) selected; |
|
249 |
} |
|
250 |
return null; |
|
251 |
} |
|
252 |
|
|
253 | 249 |
private JButton getBtnConfigView() { |
254 | 250 |
UsabilitySwingManager manager = org.gvsig.tools.swing.api.ToolsSwingLocator.getUsabilitySwingManager(); |
255 | 251 |
btConfigView = manager.createJButton(Messages.getText("Configure_view")); |
... | ... | |
302 | 298 |
private javax.swing.JList getViewList() { |
303 | 299 |
if (liViews == null) { |
304 | 300 |
ListViewModel listmodel = new ListViewModel(); |
301 |
listmodel.addCreateNewViewObj(); |
|
305 | 302 |
|
306 | 303 |
if (listmodel.addViews()) { |
307 | 304 |
JOptionPane.showMessageDialog( |
... | ... | |
313 | 310 |
|
314 | 311 |
liViews = new javax.swing.JList(); |
315 | 312 |
liViews.setModel(listmodel); |
316 |
for (int i = 0; i < liViews.getModel().getSize(); i++) { |
|
313 |
// default value: create new view |
|
314 |
liViews.setSelectedIndex(0); |
|
315 |
viewSelected(); |
|
316 |
|
|
317 |
for (int i = 1; i < liViews.getModel().getSize(); i++) { |
|
317 | 318 |
if (fframeview.getMapContext() != null) { |
318 | 319 |
|
319 | 320 |
DefaultViewDocument pvaux = |
... | ... | |
332 | 333 |
|
333 | 334 |
liViews |
334 | 335 |
.addListSelectionListener(new javax.swing.event.ListSelectionListener() { |
335 |
|
|
336 |
private int selectIndex = -1; |
|
337 | 336 |
public void valueChanged( |
338 | 337 |
javax.swing.event.ListSelectionEvent e) { |
339 |
int selectInt = |
|
340 |
((JList) e.getSource()).getSelectedIndex(); |
|
341 |
if (selectInt != selectIndex) { |
|
342 |
selectIndex = selectInt; |
|
343 |
if (selectIndex == -1) { |
|
344 |
return; |
|
345 |
} |
|
346 |
m_projectView = |
|
347 |
(DefaultViewDocument) liViews.getModel() |
|
348 |
.getElementAt(selectInt); |
|
349 |
if (m_projectView.getMapContext()!=null) { |
|
350 |
newFFrameView.setViewMapContext(m_projectView.getMapContext()); |
|
351 |
} |
|
352 |
} |
|
338 |
FFrameViewDialog.this.viewSelected(); |
|
353 | 339 |
} |
354 | 340 |
}); |
355 | 341 |
} |
356 | 342 |
|
357 | 343 |
return liViews; |
358 | 344 |
} |
345 |
|
|
346 |
protected void viewSelected() { |
|
347 |
ViewDocument v = getSelectedView(); |
|
348 |
if (v!=m_projectView) { |
|
349 |
m_projectView = v; |
|
350 |
if (m_projectView!=null && m_projectView.getMapContext()!=null) { |
|
351 |
newFFrameView.setViewMapContext(m_projectView.getMapContext()); |
|
352 |
} |
|
353 |
else { |
|
354 |
newFFrameView.setViewMapContext(null); |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
359 | 358 |
|
359 |
protected ViewDocument getSelectedView() { |
|
360 |
Object selected = this.getViewList().getSelectedValue(); |
|
361 |
ViewDocument view = null; |
|
362 |
if (selected instanceof ViewDocument) { |
|
363 |
view = (ViewDocument) selected; |
|
364 |
} |
|
365 |
else if (selected==ListViewModel.CREATE_NEW_VIEW_OBJECT) { |
|
366 |
if (this.createdView==null) { |
|
367 |
view = createView(); |
|
368 |
} |
|
369 |
else { |
|
370 |
view = this.createdView; |
|
371 |
} |
|
372 |
} |
|
373 |
return view; |
|
374 |
} |
|
375 |
|
|
376 |
private ViewDocument createView() { |
|
377 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
|
378 |
ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
|
379 |
createdView = (ViewDocument) viewManager.createDocument(); |
|
380 |
ProjectManager.getInstance().getCurrentProject().addDocument(createdView); |
|
381 |
return createdView; |
|
382 |
} |
|
383 |
|
|
384 |
private void deleteView() { |
|
385 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
|
386 |
ProjectManager.getInstance().getCurrentProject().removeDocument(createdView); |
|
387 |
createdView = null; |
|
388 |
} |
|
389 |
|
|
390 |
|
|
360 | 391 |
/** |
361 | 392 |
* This method initializes chbEnlaceVivo |
362 | 393 |
* |
... | ... | |
443 | 474 |
catch (Exception ex) { |
444 | 475 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
445 | 476 |
} |
477 |
if (createdView!=null && createdView!=getSelectedView()) { // a view was created but later de-selected |
|
478 |
deleteView(); |
|
479 |
} |
|
446 | 480 |
if (m_projectView != null) { |
447 |
newFFrameView.setView(m_projectView);
|
|
481 |
newFFrameView.setView(m_projectView);
|
|
448 | 482 |
newFFrameView.setQuality(getCbCalidad() |
449 | 483 |
.getSelectedIndex()); |
450 | 484 |
if (newFFrameView.getGrid()!=null) { |
... | ... | |
479 | 513 |
bCancelar = new javax.swing.JButton(); |
480 | 514 |
bCancelar.setText(Messages.getText("Cancelar")); |
481 | 515 |
bCancelar.addActionListener(new java.awt.event.ActionListener() { |
482 |
|
|
483 | 516 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
517 |
if (createdView!=null) { |
|
518 |
deleteView(); |
|
519 |
} |
|
484 | 520 |
newFFrameView = null; |
485 | 521 |
ApplicationLocator.getManager().getUIManager().closeWindow( |
486 | 522 |
FFrameViewDialog.this); |
Also available in: Unified diff