Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / ProjChooserPanel.java @ 6430

History | View | Annotate | Download (3.21 KB)

1
/*
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
import org.gvsig.gui.beans.swing.JButton;
13

    
14
import com.iver.andami.PluginServices;
15
import com.iver.cit.gvsig.gui.dialogs.CSSelectionDialog;
16
import java.awt.GridLayout;
17
import java.awt.FlowLayout;
18

    
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

    
30
        private ActionListener actionListener = null;
31

    
32
        /**
33
         *
34
         */
35
        public ProjChooserPanel(IProjection proj) {
36
                super();
37
                setCurProj(proj);
38
                initialize();
39
        }
40

    
41
        /**
42
         * This method initializes this
43
         *
44
         * @return void
45
         */
46
        private void initialize() {
47
        this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0));
48
        setPreferredSize(new java.awt.Dimension(330,35));
49
        this.setSize(new java.awt.Dimension(330,23));
50
        this.add(getJLblProjName(), null);
51
        this.add(getJLblProj(), null);
52
        this.add(getJBtnChangeProj(), null);
53
                initBtnChangeProj();
54
        }
55

    
56
        private void initBtnChangeProj() {
57
                getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
58
                        public void actionPerformed(java.awt.event.ActionEvent e) {
59
                                okPressed = false;
60
                                CSSelectionDialog csSelect = new CSSelectionDialog();
61
                                csSelect.setProjection(curProj);
62

    
63
                        PluginServices.getMDIManager().addView(csSelect);
64

    
65
                        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

    
96
        /**
97
         * This method initializes jButton
98
         *
99
         * @return javax.swing.JButton
100
         */
101
        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
}  //  @jve:decl-index=0:visual-constraint="10,10"