Revision 38112 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/gui/panels/ProjChooserPanel.java

View differences:

ProjChooserPanel.java
9 9
import javax.swing.JPanel;
10 10

  
11 11
import org.cresques.cts.IProjection;
12

  
12 13
import org.gvsig.andami.PluginServices;
13
import org.gvsig.app.gui.panels.crs.ICrsUIFactory;
14 14
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
15
import org.gvsig.app.project.documents.view.info.gui.CSSelectionDialog;
16 15
import org.gvsig.gui.beans.swing.JButton;
17 16

  
18

  
19 17
/**
20 18
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
21 19
 */
22 20
public class ProjChooserPanel extends CRSSelectPanel {
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 21

  
30
	/**
22
    private IProjection curProj = null;
23
    private JLabel jLblProj = null;
24
    private JLabel jLblProjName = null;
25
    private JButton jBtnChangeProj = null;
26
    private JPanel jPanelProj = null;
27
    private boolean okPressed = false;
28

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

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

  
54
	private void initBtnChangeProj() {
55
		getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
56
			public void actionPerformed(java.awt.event.ActionEvent e) {
57
				okPressed = false;
58
				
59
				ISelectCrsPanel csSelect = getUIFactory().getSelectCrsPanel(curProj, true);
51
    private void initBtnChangeProj() {
52
        getJBtnChangeProj().addActionListener(
53
            new java.awt.event.ActionListener() {
60 54

  
61
		        PluginServices.getMDIManager().addWindow(csSelect);
55
                public void actionPerformed(java.awt.event.ActionEvent e) {
56
                    okPressed = false;
62 57

  
63
		        if (csSelect.isOkPressed()) {
64
		        	curProj = csSelect.getProjection();
65
		        	jLblProj.setText(curProj.getAbrev());
66
		        	okPressed = true;
67
		        	if (actionListener != null) {
68
		        		actionListener.actionPerformed(e);
69
		        	}
70
		        }
71
			}
72
		});
73
	}
58
                    ISelectCrsPanel csSelect =
59
                        getUIFactory().getSelectCrsPanel(curProj, true);
74 60

  
75
	public JLabel getJLblProjName() {
76
		if (jLblProjName == null) {
77
	        jLblProjName = new JLabel("Proyeccion actual");
78
			jLblProjName.setText(PluginServices.getText(this,"__proyeccion_actual")); //$NON-NLS-1$
79
		}
80
		return jLblProjName;
81
	}
61
                    PluginServices.getMDIManager().addWindow(csSelect);
82 62

  
83
	public JLabel getJLabel() {
84
		return getJLblProjName();
85
	}
63
                    if (csSelect.isOkPressed()) {
64
                        curProj = csSelect.getProjection();
65
                        jLblProj.setText(curProj.getAbrev());
66
                        okPressed = true;
67
                        if (actionListener != null) {
68
                            actionListener.actionPerformed(e);
69
                        }
70
                    }
71
                }
72
            });
73
    }
86 74

  
87
	public JLabel getJLblProj() {
88
		if (jLblProj == null) {
89
	        jLblProj = new JLabel();
90
	        if (curProj!=null)
91
				jLblProj.setText(curProj.getAbrev());
92
		}
93
		return jLblProj;
94
	}
95
	public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) {
96
		jBtnChangeProj.addActionListener(al);
97
	}
75
    public JLabel getJLblProjName() {
76
        if (jLblProjName == null) {
77
            jLblProjName = new JLabel("Proyeccion actual");
78
            jLblProjName.setText(PluginServices.getText(this,
79
                "__proyeccion_actual")); //$NON-NLS-1$
80
        }
81
        return jLblProjName;
82
    }
98 83

  
99
	/**
100
	 * This method initializes jButton
101
	 *
102
	 * @return javax.swing.JButton
103
	 */
104
	public JButton getJBtnChangeProj() {
105
		if (jBtnChangeProj == null) {
106
			jBtnChangeProj = new JButton();
107
			jBtnChangeProj.setText("..."); //$NON-NLS-1$
108
			jBtnChangeProj.setPreferredSize(new java.awt.Dimension(26,26));
109
		}
110
		return jBtnChangeProj;
111
	}
112
	/**
113
	 * @return Returns the curProj.
114
	 */
115
	public IProjection getCurProj() {
116
		return curProj;
117
	}
118
	/**
119
	 * @param curProj The curProj to set.
120
	 */
121
	public void setCurProj(IProjection curProj) {
122
		this.curProj = curProj;
123
	}
124
	/**
125
	 * @return Returns the okPressed.
126
	 */
127
	public boolean isOkPressed() {
128
		return okPressed;
129
	}
130
}  //  @jve:decl-index=0:visual-constraint="10,10"
84
    public JLabel getJLabel() {
85
        return getJLblProjName();
86
    }
87

  
88
    public JLabel getJLblProj() {
89
        if (jLblProj == null) {
90
            jLblProj = new JLabel();
91
            if (curProj != null)
92
                jLblProj.setText(curProj.getAbrev());
93
        }
94
        return jLblProj;
95
    }
96

  
97
    public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) {
98
        jBtnChangeProj.addActionListener(al);
99
    }
100

  
101
    /**
102
     * This method initializes jButton
103
     * 
104
     * @return javax.swing.JButton
105
     */
106
    public JButton getJBtnChangeProj() {
107
        if (jBtnChangeProj == null) {
108
            jBtnChangeProj = new JButton();
109
            jBtnChangeProj.setText("..."); //$NON-NLS-1$
110
            jBtnChangeProj.setPreferredSize(new java.awt.Dimension(26, 26));
111
        }
112
        return jBtnChangeProj;
113
    }
114

  
115
    /**
116
     * @return Returns the curProj.
117
     */
118
    public IProjection getCurProj() {
119
        return curProj;
120
    }
121

  
122
    /**
123
     * @param curProj
124
     *            The curProj to set.
125
     */
126
    public void setCurProj(IProjection curProj) {
127
        this.curProj = curProj;
128
    }
129

  
130
    /**
131
     * @return Returns the okPressed.
132
     */
133
    public boolean isOkPressed() {
134
        return okPressed;
135
    }
136
} // @jve:decl-index=0:visual-constraint="10,10"

Also available in: Unified diff