Revision 43891 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynformfield/CoordinateReferenceSystem/JDynFormFieldCoordinateReferenceSystem.java
JDynFormFieldCoordinateReferenceSystem.java | ||
---|---|---|
16 | 16 |
import org.gvsig.app.gui.panels.CRSSelectPanelFactory; |
17 | 17 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
18 | 18 |
import org.gvsig.tools.dataTypes.CoercionException; |
19 |
import org.gvsig.tools.dynform.JDynForm.DynFormContext; |
|
19 | 20 |
import org.gvsig.tools.dynform.JDynFormField; |
20 | 21 |
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField; |
21 | 22 |
import org.gvsig.tools.dynform.spi.dynformfield.JCustomTextField; |
... | ... | |
30 | 31 |
protected IProjection currentValue = null; |
31 | 32 |
protected JTextField jtext = null; |
32 | 33 |
protected JButton jbutton = null; |
33 |
|
|
34 |
protected DynFormContextWithTargetCRS context; |
|
35 |
|
|
34 | 36 |
public JDynFormFieldCoordinateReferenceSystem(DynObject parameters, |
35 | 37 |
ServiceManager serviceManager) { |
36 | 38 |
super(parameters, serviceManager); |
37 | 39 |
this.assignedValue = (IProjection) this.getParameterValue(); |
40 |
DynFormContext theContext = this.getForm().getContext(); |
|
41 |
if( theContext instanceof DynFormContextWithTargetCRS ) { |
|
42 |
this.context = (DynFormContextWithTargetCRS)theContext; |
|
43 |
} |
|
38 | 44 |
} |
39 | 45 |
|
46 |
@Override |
|
40 | 47 |
public Object getAssignedValue() { |
41 | 48 |
return this.assignedValue; |
42 | 49 |
} |
43 | 50 |
|
51 |
@Override |
|
44 | 52 |
public void initComponent() { |
53 |
// |
|
54 |
// TODO: Aqui comprobar si hay context y presentar CRS o CRS+Transformacio |
|
55 |
// |
|
45 | 56 |
this.contents = new JPanel(); |
46 | 57 |
this.contents.setLayout(new BorderLayout()); |
47 | 58 |
|
... | ... | |
50 | 61 |
this.jtext.setEditable(false); |
51 | 62 |
this.jbutton = new JButton("..."); |
52 | 63 |
this.jbutton.addActionListener(new ActionListener() { |
64 |
@Override |
|
53 | 65 |
public void actionPerformed(ActionEvent e) { |
54 | 66 |
onClickBrowse(); |
55 | 67 |
} |
... | ... | |
65 | 77 |
fireFieldEnterEvent(); |
66 | 78 |
this.problemIndicator().restore(); |
67 | 79 |
|
80 |
// TODO: Aqui comprobar si tenemos context y de tenerlo presentar |
|
81 |
// el dialogo con transformacion, y si no, el de sin transformacion. |
|
82 |
// A la vuelta del dialogo con transformacion, meter la transformacion |
|
83 |
// en el context y actualizar el jtext |
|
84 |
|
|
68 | 85 |
ISelectCrsPanel csSelect = CRSSelectPanelFactory.getUIFactory().getSelectCrsPanel(this.currentValue, true); |
69 | 86 |
ToolsSwingLocator.getWindowManager().showWindow((JComponent) csSelect, Messages.getText("selecciona_sistema_de_referencia"), MODE.DIALOG); |
70 | 87 |
if (csSelect.isOkPressed()) { |
... | ... | |
73 | 90 |
} |
74 | 91 |
} |
75 | 92 |
|
93 |
@Override |
|
76 | 94 |
public boolean hasValidValue() { |
77 | 95 |
return true; |
78 | 96 |
} |
79 | 97 |
|
98 |
@Override |
|
80 | 99 |
public void focusGained(FocusEvent arg0) { |
81 | 100 |
fireFieldEnterEvent(); |
82 | 101 |
this.problemIndicator().restore(); |
83 | 102 |
} |
84 | 103 |
|
104 |
@Override |
|
85 | 105 |
public void focusLost(FocusEvent arg0) { |
86 | 106 |
fireFieldExitEvent(); |
87 | 107 |
} |
88 | 108 |
|
109 |
@Override |
|
89 | 110 |
public void setValue(Object value) { |
90 | 111 |
IProjection x = null; |
91 | 112 |
try { |
92 | 113 |
x = (IProjection) this.getDefinition().getDataType().coerce(value); |
93 | 114 |
} catch (CoercionException e) { |
94 |
throw new IllegalFieldValue(this, e.getMessage()); |
|
115 |
throw new AbstractJDynFormField.IllegalFieldValue(this, e.getMessage());
|
|
95 | 116 |
} |
96 | 117 |
this.currentValue = x; |
97 | 118 |
if (x != null) { |
... | ... | |
100 | 121 |
this.assignedValue = x; |
101 | 122 |
} |
102 | 123 |
|
124 |
@Override |
|
103 | 125 |
public Object getValue() { |
104 | 126 |
return this.currentValue; |
105 | 127 |
} |
Also available in: Unified diff