Statistics
| Revision:

root / tags / v2_0_0_Build_2058 / applications / appgvSIG / src / org / gvsig / app / gui / panels / ProjChooserPanel.java @ 39222

History | View | Annotate | Download (4.2 KB)

1
/*
2
 * Created on 30-ene-2005
3
 */
4
package org.gvsig.app.gui.panels;
5

    
6
import java.awt.FlowLayout;
7
import java.awt.GridBagConstraints;
8
import java.awt.GridBagLayout;
9
import java.awt.GridLayout;
10

    
11
import javax.swing.JLabel;
12
import javax.swing.JPanel;
13

    
14
import org.cresques.cts.IProjection;
15

    
16
import org.gvsig.andami.PluginServices;
17
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
18
import org.gvsig.gui.beans.swing.JButton;
19

    
20
/**
21
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
22
 */
23
public class ProjChooserPanel extends CRSSelectPanel {
24

    
25
    private IProjection curProj = null;
26
    private JLabel jLblProj = null;
27
    private JLabel jLblProjName = null;
28
    private JButton jBtnChangeProj = null;
29
    private JPanel jPanelProj = null;
30
    private boolean okPressed = false;
31

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

    
41
    /**
42
     * This method initializes this
43
     * 
44
     * @return void
45
     */
46
    private void initialize() {
47
        GridLayout gl = new GridLayout(1,2);
48
        
49
        this.setLayout(gl); // new FlowLayout(FlowLayout.LEFT, 15, 0));
50
        this.add(getJLblProjName());
51
        
52
        JPanel secondHalf = new JPanel(new GridBagLayout());
53
        GridBagConstraints c = new GridBagConstraints();
54
        
55
        c.fill = GridBagConstraints.HORIZONTAL;
56
        c.weightx = 1.0;   //request any extra vertical space
57
        c.gridx = 0;      
58
        c.gridwidth = 1;  
59
        c.gridy = 0;      
60
        secondHalf.add(getJLblProj(), c);
61
        
62
        c.fill = GridBagConstraints.NONE;
63
        c.weightx = 0.0;  
64
        c.gridx = 1;      
65
        secondHalf.add(getJBtnChangeProj(), c);
66

    
67
        this.add(secondHalf);
68
        initBtnChangeProj();
69
    }
70

    
71
    private void initBtnChangeProj() {
72
        getJBtnChangeProj().addActionListener(
73
            new java.awt.event.ActionListener() {
74

    
75
                public void actionPerformed(java.awt.event.ActionEvent e) {
76
                    okPressed = false;
77

    
78
                    ISelectCrsPanel csSelect =
79
                        getUIFactory().getSelectCrsPanel(curProj, true);
80

    
81
                    PluginServices.getMDIManager().addWindow(csSelect);
82

    
83
                    if (csSelect.isOkPressed()) {
84
                        curProj = csSelect.getProjection();
85
                        jLblProj.setText(curProj.getAbrev());
86
                        okPressed = true;
87
                        if (actionListener != null) {
88
                            actionListener.actionPerformed(e);
89
                        }
90
                    }
91
                }
92
            });
93
    }
94

    
95
    public JLabel getJLblProjName() {
96
        if (jLblProjName == null) {
97
            jLblProjName = new JLabel("Proyeccion actual");
98
            jLblProjName.setText(PluginServices.getText(this,
99
                "__proyeccion_actual")); //$NON-NLS-1$
100
        }
101
        return jLblProjName;
102
    }
103

    
104
    public JLabel getJLabel() {
105
        return getJLblProjName();
106
    }
107

    
108
    public JLabel getJLblProj() {
109
        if (jLblProj == null) {
110
            jLblProj = new JLabel();
111
            jLblProj.setAlignmentX(JLabel.CENTER_ALIGNMENT);
112
            if (curProj != null)
113
                jLblProj.setText(curProj.getAbrev());
114
        }
115
        return jLblProj;
116
    }
117

    
118
    public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) {
119
        jBtnChangeProj.addActionListener(al);
120
    }
121

    
122
    /**
123
     * This method initializes jButton
124
     * 
125
     * @return javax.swing.JButton
126
     */
127
    public JButton getJBtnChangeProj() {
128
        if (jBtnChangeProj == null) {
129
            jBtnChangeProj = new JButton();
130
            jBtnChangeProj.setText("..."); //$NON-NLS-1$
131
            // jBtnChangeProj.setPreferredSize(new java.awt.Dimension(26, 26));
132
        }
133
        return jBtnChangeProj;
134
    }
135

    
136
    /**
137
     * @return Returns the curProj.
138
     */
139
    public IProjection getCurProj() {
140
        return curProj;
141
    }
142

    
143
    /**
144
     * @param curProj
145
     *            The curProj to set.
146
     */
147
    public void setCurProj(IProjection curProj) {
148
        this.curProj = curProj;
149
    }
150

    
151
    /**
152
     * @return Returns the okPressed.
153
     */
154
    public boolean isOkPressed() {
155
        return okPressed;
156
    }
157
} // @jve:decl-index=0:visual-constraint="10,10"