Revision 42614
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.projection.app/org.gvsig.projection.app.proj4j/src/main/java/org/gvsig/proj/app/mainplugin/CoordinateReferenceSystemSelectionDialog.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.awt.BorderLayout; |
26 | 26 |
import java.awt.Dimension; |
27 |
import java.awt.FlowLayout; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import javax.swing.JComponent; |
|
28 | 30 |
|
29 |
import javax.swing.JButton; |
|
30 | 31 |
import javax.swing.JPanel; |
31 | 32 |
|
32 |
import org.cresques.Messages; |
|
33 | 33 |
import org.cresques.cts.IProjection; |
34 | 34 |
|
35 | 35 |
import org.gvsig.andami.PluginServices; |
... | ... | |
40 | 40 |
import org.gvsig.proj.cts.DefaultIProjection; |
41 | 41 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSelectorComponent; |
42 | 42 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingLocator; |
43 |
import org.gvsig.tools.ToolsLocator; |
|
44 |
import org.gvsig.tools.i18n.I18nManager; |
|
43 | 45 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
44 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
|
46 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
47 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
45 | 48 |
|
46 | 49 |
/** |
47 | 50 |
* ISelectCrsPanel implementation based on the org.gvsig.proj library. |
... | ... | |
55 | 58 |
private boolean okPressed = false; |
56 | 59 |
private IProjection lastProjection = null; |
57 | 60 |
private CoordinateReferenceSystemSelectorComponent component; |
58 |
private JPanel panel; |
|
59 | 61 |
|
60 | 62 |
/** |
61 | 63 |
* Constructor. |
62 | 64 |
*/ |
63 | 65 |
public CoordinateReferenceSystemSelectionDialog() { |
64 |
super(new BorderLayout(4, 0)); |
|
66 |
super(); |
|
67 |
this.setLayout(new BorderLayout()); |
|
65 | 68 |
|
66 |
add(getContentPanel(), BorderLayout.CENTER); |
|
69 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
70 |
WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
71 |
final Dialog dialogPanel = windowManager.createDialog( |
|
72 |
getContentPanel(), |
|
73 |
i18nManager.getTranslation("selecciona_sistema_de_referencia"), |
|
74 |
i18nManager.getTranslation("reference_system"), |
|
75 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
76 |
); |
|
77 |
|
|
78 |
add(dialogPanel.asJComponent(), BorderLayout.CENTER); |
|
79 |
dialogPanel.addActionListener(new ActionListener() { |
|
67 | 80 |
|
68 |
JPanel buttonsPanel = |
|
69 |
new JPanel(new FlowLayout(FlowLayout.RIGHT, 4, 4)); |
|
70 |
add(buttonsPanel, BorderLayout.SOUTH); |
|
71 |
|
|
72 |
UsabilitySwingManager usabilitySwingManager = |
|
73 |
ToolsSwingLocator.getUsabilitySwingManager(); |
|
74 |
JButton acceptButton = |
|
75 |
usabilitySwingManager.createJButton(Messages.getText("Aceptar")); |
|
76 |
buttonsPanel.add(acceptButton); |
|
77 |
JButton cancelButton = |
|
78 |
usabilitySwingManager.createJButton(Messages.getText("Cancelar")); |
|
79 |
buttonsPanel.add(cancelButton); |
|
80 |
|
|
81 |
acceptButton.addActionListener(new java.awt.event.ActionListener() { |
|
82 |
|
|
83 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
84 |
PluginServices.getMDIManager().closeWindow( |
|
85 |
CoordinateReferenceSystemSelectionDialog.this); |
|
86 |
okPressed = true; |
|
81 |
@Override |
|
82 |
public void actionPerformed(ActionEvent ae) { |
|
83 |
switch( dialogPanel.getAction()) { |
|
84 |
case WindowManager_v2.BUTTON_OK: |
|
85 |
okPressed = true; |
|
86 |
break; |
|
87 |
case WindowManager_v2.BUTTON_CANCEL: |
|
88 |
setProjection(lastProjection); |
|
89 |
okPressed = false; |
|
90 |
break; |
|
91 |
} |
|
92 |
setVisible(false); |
|
87 | 93 |
} |
88 | 94 |
}); |
89 |
cancelButton.addActionListener(new java.awt.event.ActionListener() { |
|
90 |
|
|
91 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
92 |
setProjection(lastProjection); |
|
93 |
PluginServices.getMDIManager().closeWindow( |
|
94 |
CoordinateReferenceSystemSelectionDialog.this); |
|
95 |
okPressed = false; |
|
96 |
} |
|
97 |
}); |
|
98 | 95 |
} |
99 | 96 |
|
97 |
@Override |
|
100 | 98 |
public WindowInfo getWindowInfo() { |
101 | 99 |
WindowInfo m_viewinfo = |
102 | 100 |
new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
... | ... | |
108 | 106 |
return m_viewinfo; |
109 | 107 |
} |
110 | 108 |
|
109 |
@Override |
|
111 | 110 |
public boolean isOkPressed() { |
112 | 111 |
return okPressed; |
113 | 112 |
} |
... | ... | |
115 | 114 |
/** |
116 | 115 |
* @return |
117 | 116 |
*/ |
117 |
@Override |
|
118 | 118 |
public IProjection getProjection() { |
119 | 119 |
CoordinateReferenceSystem crs = |
120 | 120 |
component.getSelectedCoordinateReferenceSystem(); |
... | ... | |
124 | 124 |
return new DefaultIProjection(crs); |
125 | 125 |
} |
126 | 126 |
|
127 |
protected JPanel getContentPanel() {
|
|
128 |
if (panel == null) {
|
|
129 |
panel = new JPanel(); |
|
127 |
protected JComponent getContentPanel() {
|
|
128 |
if (component == null) {
|
|
129 |
|
|
130 | 130 |
component = |
131 | 131 |
CoordinateReferenceSystemSwingLocator.getSwingManager() |
132 | 132 |
.createCoordinateReferenceSystemSelectionComponent(); |
133 |
panel.add(component.asJComponent()); |
|
134 | 133 |
} |
135 | 134 |
|
136 |
return panel;
|
|
135 |
return component.asJComponent();
|
|
137 | 136 |
} |
138 | 137 |
|
139 | 138 |
/** |
140 | 139 |
* @param proj |
141 | 140 |
*/ |
141 |
@Override |
|
142 | 142 |
public void setProjection(IProjection proj) { |
143 | 143 |
CoordinateReferenceSystem crs = null; |
144 | 144 |
lastProjection = proj; |
... | ... | |
148 | 148 |
component.setCoordinateReferenceSystem(crs); |
149 | 149 |
} |
150 | 150 |
|
151 |
@Override |
|
151 | 152 |
public Object getWindowProfile() { |
152 | 153 |
return WindowInfo.DIALOG_PROFILE; |
153 | 154 |
} |
Also available in: Unified diff