root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / gui / DistanceUnitsConfig.java @ 9956
History | View | Annotate | Download (4.79 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.gui; |
---|---|
2 |
|
3 |
import javax.swing.JComboBox; |
4 |
import javax.swing.JComponent; |
5 |
import javax.swing.JLabel; |
6 |
import javax.swing.JPanel; |
7 |
|
8 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
9 |
|
10 |
import com.iver.andami.PluginServices; |
11 |
import com.iver.andami.ui.mdiManager.IWindow; |
12 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
13 |
import com.iver.cit.gvsig.project.documents.layout.Attributes; |
14 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
15 |
|
16 |
|
17 |
/**
|
18 |
* DOCUMENT ME!
|
19 |
*
|
20 |
* @author Vicente Caballero Navarro
|
21 |
*/
|
22 |
public class DistanceUnitsConfig extends JPanel implements IWindow { |
23 |
private static String[] unitsNames = null; |
24 |
private JLabel lblDistanceUnits = null; |
25 |
private JComboBox cmbDistanceUnits = null; |
26 |
private IProjectView view = null; |
27 |
private AcceptCancelPanel acceptCancel = null; |
28 |
private boolean isAcceppted = false; |
29 |
|
30 |
/**
|
31 |
* This is the default constructor
|
32 |
*
|
33 |
* @param view DOCUMENT ME!
|
34 |
*/
|
35 |
public DistanceUnitsConfig(IProjectView view) {
|
36 |
super();
|
37 |
this.view = view;
|
38 |
initialize(); |
39 |
} |
40 |
|
41 |
/**
|
42 |
* This method initializes this
|
43 |
*/
|
44 |
private void initialize() { |
45 |
this.setSize(331, 74); |
46 |
this.add(getLblDistanceUnits(), null); |
47 |
this.add(getCmbDistanceUnits(), null); |
48 |
this.add(getAcceptCancel(), null); |
49 |
} |
50 |
|
51 |
/**
|
52 |
* This method initializes jLabel5
|
53 |
*
|
54 |
* @return javax.swing.JLabel
|
55 |
*/
|
56 |
private javax.swing.JLabel getLblDistanceUnits() {
|
57 |
if (lblDistanceUnits == null) { |
58 |
lblDistanceUnits = new javax.swing.JLabel();
|
59 |
lblDistanceUnits.setText(PluginServices.getText(this,
|
60 |
"distance_units") + ":"); |
61 |
} |
62 |
|
63 |
return lblDistanceUnits;
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* This method initializes cmbDistanceUnits
|
68 |
*
|
69 |
* @return javax.swing.JComboBox
|
70 |
*/
|
71 |
private javax.swing.JComboBox getCmbDistanceUnits() {
|
72 |
if (cmbDistanceUnits == null) { |
73 |
cmbDistanceUnits = new javax.swing.JComboBox(getUnitsNames());
|
74 |
cmbDistanceUnits.setPreferredSize(new java.awt.Dimension(200, 20)); |
75 |
cmbDistanceUnits.setEditable(false);
|
76 |
cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort() |
77 |
.getDistanceUnits()); |
78 |
cmbDistanceUnits.addActionListener(new java.awt.event.ActionListener() {
|
79 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
80 |
//view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
|
81 |
} |
82 |
}); |
83 |
} |
84 |
|
85 |
return cmbDistanceUnits;
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* DOCUMENT ME!
|
90 |
*
|
91 |
* @return DOCUMENT ME!
|
92 |
*/
|
93 |
private String[] getUnitsNames() { |
94 |
if (unitsNames == null) { |
95 |
unitsNames = new String[Attributes.NAMES.length]; |
96 |
|
97 |
int i = 0; |
98 |
|
99 |
for (i = 0; i < Attributes.NAMES.length; i++) { |
100 |
unitsNames[i] = PluginServices.getText(this, Attributes.NAMES[i]); |
101 |
} |
102 |
|
103 |
//unitsNames[i]=PluginServices.getText(this, Attributes.DEGREES);
|
104 |
} |
105 |
|
106 |
return unitsNames;
|
107 |
} |
108 |
|
109 |
/**
|
110 |
* DOCUMENT ME!
|
111 |
*
|
112 |
* @return DOCUMENT ME!
|
113 |
*/
|
114 |
public WindowInfo getWindowInfo() {
|
115 |
WindowInfo wi = new WindowInfo(WindowInfo.MODALDIALOG);
|
116 |
wi.setTitle(PluginServices.getText(this, "distance_units")); |
117 |
|
118 |
JComponent statusBar = PluginServices.getMainFrame().getStatusBar();
|
119 |
JComponent component = PluginServices.getMainFrame().getComponentByName("coords"); |
120 |
wi.setX(component.getX()); |
121 |
wi.setY(statusBar.getY()); |
122 |
|
123 |
return wi;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* DOCUMENT ME!
|
128 |
*
|
129 |
* @return DOCUMENT ME!
|
130 |
*/
|
131 |
private AcceptCancelPanel getAcceptCancel() {
|
132 |
if (this.acceptCancel == null) { |
133 |
this.acceptCancel = new AcceptCancelPanel(new java.awt.event.ActionListener() { |
134 |
public void actionPerformed( |
135 |
java.awt.event.ActionEvent e) { |
136 |
view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex()); |
137 |
isAcceppted = true;
|
138 |
PluginServices.getMDIManager().closeWindow(DistanceUnitsConfig.this); |
139 |
} |
140 |
}, |
141 |
new java.awt.event.ActionListener() {
|
142 |
public void actionPerformed( |
143 |
java.awt.event.ActionEvent e) { |
144 |
PluginServices.getMDIManager().closeWindow(DistanceUnitsConfig.this); |
145 |
} |
146 |
}); |
147 |
this.acceptCancel.setBounds(5, 150, this.getWidth() - 10, 30); |
148 |
} |
149 |
|
150 |
return this.acceptCancel; |
151 |
} |
152 |
} // @jve:decl-index=0:visual-constraint="10,10"
|