root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / ProjChooserPanel.java @ 6430
History | View | Annotate | Download (3.21 KB)
1 | 6117 | jaume | /*
|
---|---|---|---|
2 | * Created on 30-ene-2005
|
||
3 | */
|
||
4 | package com.iver.cit.gvsig.gui.panels; |
||
5 | |||
6 | import java.awt.event.ActionListener; |
||
7 | |||
8 | import javax.swing.JLabel; |
||
9 | import javax.swing.JPanel; |
||
10 | |||
11 | import org.cresques.cts.IProjection; |
||
12 | 6119 | jaume | import org.gvsig.gui.beans.swing.JButton; |
13 | 6117 | jaume | |
14 | import com.iver.andami.PluginServices; |
||
15 | 6118 | jaume | import com.iver.cit.gvsig.gui.dialogs.CSSelectionDialog; |
16 | 6119 | jaume | import java.awt.GridLayout; |
17 | import java.awt.FlowLayout; |
||
18 | 6117 | jaume | |
19 | /**
|
||
20 | * @author Luis W. Sevilla (sevilla_lui@gva.es)
|
||
21 | */
|
||
22 | public class ProjChooserPanel extends JPanel { |
||
23 | private IProjection curProj=null; |
||
24 | private JLabel jLblProj = null; |
||
25 | private JLabel jLblProjName = null; |
||
26 | private JButton jBtnChangeProj = null; |
||
27 | private JPanel jPanelProj = null; |
||
28 | private boolean okPressed = false; |
||
29 | 6119 | jaume | |
30 | 6117 | jaume | private ActionListener actionListener = null; |
31 | |||
32 | /**
|
||
33 | 6119 | jaume | *
|
34 | 6117 | jaume | */
|
35 | public ProjChooserPanel(IProjection proj) {
|
||
36 | super();
|
||
37 | setCurProj(proj); |
||
38 | initialize(); |
||
39 | } |
||
40 | |||
41 | /**
|
||
42 | * This method initializes this
|
||
43 | 6119 | jaume | *
|
44 | 6117 | jaume | * @return void
|
45 | */
|
||
46 | private void initialize() { |
||
47 | 6119 | jaume | this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0)); |
48 | 6117 | jaume | setPreferredSize(new java.awt.Dimension(330,35)); |
49 | 6119 | jaume | this.setSize(new java.awt.Dimension(330,23)); |
50 | this.add(getJLblProjName(), null); |
||
51 | this.add(getJLblProj(), null); |
||
52 | this.add(getJBtnChangeProj(), null); |
||
53 | 6117 | jaume | initBtnChangeProj(); |
54 | } |
||
55 | 6119 | jaume | |
56 | 6117 | jaume | private void initBtnChangeProj() { |
57 | 6119 | jaume | getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
|
58 | 6117 | jaume | public void actionPerformed(java.awt.event.ActionEvent e) { |
59 | okPressed = false;
|
||
60 | CSSelectionDialog csSelect = new CSSelectionDialog();
|
||
61 | csSelect.setProjection(curProj); |
||
62 | 6119 | jaume | |
63 | 6117 | jaume | PluginServices.getMDIManager().addView(csSelect); |
64 | 6119 | jaume | |
65 | 6117 | jaume | if (csSelect.isOkPressed()) {
|
66 | curProj = csSelect.getProjection(); |
||
67 | jLblProj.setText(curProj.getAbrev()); |
||
68 | okPressed = true;
|
||
69 | if (actionListener != null) { |
||
70 | actionListener.actionPerformed(e); |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 | }); |
||
75 | } |
||
76 | |||
77 | public JLabel getJLblProjName() { |
||
78 | if (jLblProjName == null) { |
||
79 | jLblProjName = new JLabel("Proyeccion actual"); |
||
80 | jLblProjName.setText(PluginServices.getText(this,"__proyeccion_actual")); //$NON-NLS-1$ |
||
81 | } |
||
82 | return jLblProjName;
|
||
83 | } |
||
84 | |||
85 | public JLabel getJLblProj() { |
||
86 | if (jLblProj == null) { |
||
87 | jLblProj = new JLabel(); |
||
88 | jLblProj.setText(curProj.getAbrev()); |
||
89 | } |
||
90 | return jLblProj;
|
||
91 | } |
||
92 | public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
||
93 | jBtnChangeProj.addActionListener(al); |
||
94 | } |
||
95 | 6119 | jaume | |
96 | 6117 | jaume | /**
|
97 | 6119 | jaume | * This method initializes jButton
|
98 | *
|
||
99 | * @return javax.swing.JButton
|
||
100 | */
|
||
101 | 6117 | jaume | public JButton getJBtnChangeProj() { |
102 | if (jBtnChangeProj == null) { |
||
103 | jBtnChangeProj = new JButton(); |
||
104 | jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
||
105 | } |
||
106 | return jBtnChangeProj;
|
||
107 | } |
||
108 | /**
|
||
109 | * @return Returns the curProj.
|
||
110 | */
|
||
111 | public IProjection getCurProj() {
|
||
112 | return curProj;
|
||
113 | } |
||
114 | /**
|
||
115 | * @param curProj The curProj to set.
|
||
116 | */
|
||
117 | public void setCurProj(IProjection curProj) { |
||
118 | this.curProj = curProj;
|
||
119 | } |
||
120 | /**
|
||
121 | * @return Returns the okPressed.
|
||
122 | */
|
||
123 | public boolean isOkPressed() { |
||
124 | return okPressed;
|
||
125 | } |
||
126 | /**
|
||
127 | * @param actionListener The actionListener to set.
|
||
128 | */
|
||
129 | public void addActionListener(ActionListener actionListener) { |
||
130 | this.actionListener = actionListener;
|
||
131 | } |
||
132 | 6119 | jaume | } // @jve:decl-index=0:visual-constraint="10,10" |