root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / CRSSelectionDialogPanel.java @ 7823
History | View | Annotate | Download (4.24 KB)
1 |
package org.gvsig.crs.gui; |
---|---|
2 |
|
3 |
import java.awt.event.ActionEvent; |
4 |
import java.awt.event.ActionListener; |
5 |
|
6 |
import javax.swing.JOptionPane; |
7 |
import javax.swing.JPanel; |
8 |
import javax.swing.ListSelectionModel; |
9 |
import javax.swing.event.ListSelectionEvent; |
10 |
import javax.swing.event.ListSelectionListener; |
11 |
|
12 |
import org.cresques.cts.IProjection; |
13 |
|
14 |
import com.iver.andami.PluginServices; |
15 |
import com.iver.andami.ui.mdiManager.IWindow; |
16 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
17 |
import com.iver.cit.gvsig.gui.dialogs.CSSelectionDialog; |
18 |
|
19 |
public class CRSSelectionDialogPanel extends JPanel implements IWindow, ListSelectionListener, ActionListener { |
20 |
|
21 |
private static final long serialVersionUID = 1L; |
22 |
|
23 |
JPanel contentPane = null; |
24 |
public CRSViewPanel vp = null; |
25 |
private IProjection lastProj = null; |
26 |
int code = 0; |
27 |
|
28 |
private boolean okPressed = false; |
29 |
|
30 |
public CRSSelectionDialogPanel(){
|
31 |
super();
|
32 |
inicializate(); |
33 |
} |
34 |
|
35 |
public void inicializate(){ |
36 |
vp = new CRSViewPanel();
|
37 |
this.add(getContentPanel(), null); |
38 |
|
39 |
ListSelectionModel rowSM = vp.ep.getJTable().getSelectionModel();
|
40 |
rowSM.addListSelectionListener(this);
|
41 |
|
42 |
vp.getButtonAccept().addActionListener(new java.awt.event.ActionListener() {
|
43 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
44 |
lastProj = getProjection(); |
45 |
|
46 |
if (lastProj != null){ |
47 |
PluginServices.getMDIManager().closeWindow(CRSSelectionDialogPanel.this); |
48 |
okPressed = true;
|
49 |
} |
50 |
else {
|
51 |
okPressed = false;
|
52 |
} |
53 |
} |
54 |
}); |
55 |
vp.getButtonCancel().addActionListener(new java.awt.event.ActionListener() {
|
56 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
57 |
setProjection(lastProj); |
58 |
PluginServices.getMDIManager().closeWindow(CRSSelectionDialogPanel.this); |
59 |
okPressed = false;
|
60 |
} |
61 |
}); |
62 |
} |
63 |
|
64 |
public boolean isOkPressed() { return okPressed; } |
65 |
|
66 |
public CRSViewPanel getProjPanel() {
|
67 |
return (CRSViewPanel) getContentPanel();
|
68 |
} |
69 |
|
70 |
public JPanel getContentPanel() { |
71 |
if (contentPane == null) { |
72 |
contentPane = vp; |
73 |
|
74 |
} |
75 |
return contentPane;
|
76 |
} |
77 |
|
78 |
public void valueChanged(ListSelectionEvent e) { |
79 |
String[] not_soported = {"engineering", "vertical", "compound", "geocentric"}; |
80 |
boolean soported = true; |
81 |
ListSelectionModel lsm = (ListSelectionModel)e.getSource(); |
82 |
if (lsm.isSelectionEmpty()) {
|
83 |
vp.ep.selectedRowTable = -1;
|
84 |
vp.ep.setCodeCRS(-1);
|
85 |
vp.getButtonAccept().setEnabled(false);
|
86 |
vp.ep.getInfoCrs().setEnabled(false);
|
87 |
setCode(0);
|
88 |
} |
89 |
else {
|
90 |
vp.ep.selectedRowTable = lsm.getMinSelectionIndex(); |
91 |
String crs_kind = (String)vp.ep.dtm.getValueAt(vp.ep.selectedRowTable,2); |
92 |
for (int i = 0; i < not_soported.length; i++) { |
93 |
if (crs_kind.equals(not_soported[i])){
|
94 |
soported = false;
|
95 |
} |
96 |
} |
97 |
if (soported){
|
98 |
vp.ep.setCodeCRS(Integer.parseInt((String)vp.ep.dtm.getValueAt(vp.ep.selectedRowTable,0))); |
99 |
vp.ep.setWKT(); |
100 |
setCode(vp.ep.epsg_code); |
101 |
vp.getButtonAccept().setEnabled(true);
|
102 |
|
103 |
} |
104 |
else {
|
105 |
JOptionPane.showMessageDialog(this, "CRS no soportado.", "Warning...", |
106 |
JOptionPane.WARNING_MESSAGE);
|
107 |
vp.ep.setCodeCRS(-1);
|
108 |
setCode(0);
|
109 |
vp.getButtonAccept().setEnabled(false);
|
110 |
} |
111 |
vp.ep.getInfoCrs().setEnabled(true);
|
112 |
|
113 |
} |
114 |
|
115 |
} |
116 |
|
117 |
public void setCode(int cod){ |
118 |
code = cod; |
119 |
} |
120 |
|
121 |
public int getCode(){ |
122 |
return code;
|
123 |
} |
124 |
|
125 |
public IProjection getProjection() {
|
126 |
return (IProjection) getProjPanel().getProjection();
|
127 |
} |
128 |
/**
|
129 |
* @param proj
|
130 |
*/
|
131 |
public void setProjection(IProjection proj) { |
132 |
lastProj = proj; |
133 |
getProjPanel().setProjection(proj); |
134 |
} |
135 |
|
136 |
public String getProjectionAbrev(){ |
137 |
return (String) getProjPanel().getProjection().getAbrev(); |
138 |
} |
139 |
|
140 |
public void actionPerformed(ActionEvent arg0) { |
141 |
// TODO Auto-generated method stub
|
142 |
|
143 |
} |
144 |
|
145 |
public WindowInfo getWindowInfo() {
|
146 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
147 |
m_viewinfo.setTitle(PluginServices.getText(this, "Nuevo CRS")); |
148 |
return m_viewinfo;
|
149 |
} |
150 |
} |