root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / wizard / MainPanel.java @ 10787
History | View | Annotate | Download (4.93 KB)
1 | 10603 | lmfernandez | package org.gvsig.crs.gui.panels.wizard; |
---|---|---|---|
2 | |||
3 | import java.awt.BorderLayout; |
||
4 | import java.awt.CardLayout; |
||
5 | import java.awt.FlowLayout; |
||
6 | import java.awt.event.ActionEvent; |
||
7 | import java.awt.event.ActionListener; |
||
8 | |||
9 | import javax.swing.JButton; |
||
10 | import javax.swing.JPanel; |
||
11 | |||
12 | 10786 | lmfernandez | import com.iver.andami.PluginServices; |
13 | import com.iver.andami.ui.mdiManager.IWindow; |
||
14 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
15 | 10603 | lmfernandez | |
16 | 10786 | lmfernandez | |
17 | 10603 | lmfernandez | /**
|
18 | *
|
||
19 | * @author Luisa Marina Fern?ndez (luisam.fernandez@uclm.es)
|
||
20 | *
|
||
21 | */
|
||
22 | 10786 | lmfernandez | public class MainPanel extends JPanel implements ActionListener,IWindow { |
23 | 10603 | lmfernandez | |
24 | 10604 | lmfernandez | private static final long serialVersionUID = 1L; |
25 | 10603 | lmfernandez | private JPanel pCard; |
26 | private JPanel pSouth; |
||
27 | |||
28 | private JButton btnCancelar; |
||
29 | private JButton btnSiguiente; |
||
30 | private JButton btnAnterior; |
||
31 | private JButton btnFinalizar; |
||
32 | |||
33 | private DefCrsUsr pCrsUsr;
|
||
34 | private DefinirDatum pDatum;
|
||
35 | private DefSistCoordenadas pSistCoord;
|
||
36 | |||
37 | final static String CRSUSUARIOPANEL = "CrsUsuario"; |
||
38 | final static String DEFINIRDATUMPANEL = "DefinirDatum"; |
||
39 | final static String SISTEMACOORDENADASPANEL = "SistemaCoordenadas"; |
||
40 | |||
41 | public MainPanel() {
|
||
42 | super();
|
||
43 | this.setLayout(new BorderLayout()); |
||
44 | this.add(getPCard(),BorderLayout.CENTER); |
||
45 | this.add(getPSouth(),BorderLayout.SOUTH); |
||
46 | } |
||
47 | /**
|
||
48 | * Inicilizar el bot?n Anterior
|
||
49 | * @return
|
||
50 | */
|
||
51 | public JButton getBtnAnterior() { |
||
52 | if(btnAnterior==null){ |
||
53 | btnAnterior=new JButton(); |
||
54 | 10787 | lmfernandez | btnAnterior.setText(PluginServices.getText(this,"wz_anterior")); |
55 | 10603 | lmfernandez | btnAnterior.addActionListener(this);
|
56 | |||
57 | } |
||
58 | return btnAnterior;
|
||
59 | } |
||
60 | /**
|
||
61 | * Inicilizar el bot?n Cancelar
|
||
62 | * @return
|
||
63 | */
|
||
64 | public JButton getBtnCancelar() { |
||
65 | if(btnCancelar==null){ |
||
66 | btnCancelar=new JButton(); |
||
67 | 10787 | lmfernandez | btnCancelar.setText(PluginServices.getText(this,"wz_cancel")); |
68 | 10603 | lmfernandez | btnCancelar.addActionListener(this);
|
69 | } |
||
70 | return btnCancelar;
|
||
71 | } |
||
72 | /**
|
||
73 | * Inicilizar el bot?n Finalizar
|
||
74 | * @return
|
||
75 | */
|
||
76 | public JButton getBtnFinalizar() { |
||
77 | if(btnFinalizar==null){ |
||
78 | btnFinalizar=new JButton(); |
||
79 | 10787 | lmfernandez | btnFinalizar.setText(PluginServices.getText(this,"wz_fin")); |
80 | 10603 | lmfernandez | btnFinalizar.addActionListener(this);
|
81 | } |
||
82 | return btnFinalizar;
|
||
83 | } |
||
84 | /**
|
||
85 | * Inicilizar el bot?n Siguiente
|
||
86 | * @return
|
||
87 | */
|
||
88 | public JButton getBtnSiguiente() { |
||
89 | if(btnSiguiente==null){ |
||
90 | btnSiguiente=new JButton(); |
||
91 | 10787 | lmfernandez | btnSiguiente.setText(PluginServices.getText(this,"wz_siguiente")); |
92 | 10603 | lmfernandez | btnSiguiente.addActionListener(this);
|
93 | } |
||
94 | return btnSiguiente;
|
||
95 | } |
||
96 | /**
|
||
97 | * Inicilizar el panel que maneja los subpaneles del asistente
|
||
98 | * @return
|
||
99 | */
|
||
100 | public JPanel getPCard() { |
||
101 | if(pCard==null){ |
||
102 | pCard=new JPanel(); |
||
103 | pCard.setLayout(new CardLayout()); |
||
104 | |||
105 | pCard.add(CRSUSUARIOPANEL,getPCrsUsr()); |
||
106 | pCard.add(DEFINIRDATUMPANEL,getPDatum()); |
||
107 | pCard.add(SISTEMACOORDENADASPANEL,getPSistCoord()); |
||
108 | |||
109 | } |
||
110 | return pCard;
|
||
111 | } |
||
112 | /**
|
||
113 | * Iniciliza el panel que contiene los botones del asistente
|
||
114 | * @return
|
||
115 | */
|
||
116 | public JPanel getPSouth() { |
||
117 | if(pSouth==null){ |
||
118 | pSouth=new JPanel(); |
||
119 | pSouth.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
||
120 | pSouth.add(getBtnCancelar()); |
||
121 | pSouth.add(getBtnAnterior()); |
||
122 | pSouth.add(getBtnSiguiente()); |
||
123 | pSouth.add(getBtnFinalizar()); |
||
124 | getBtnFinalizar().setVisible(false);
|
||
125 | 10786 | lmfernandez | getBtnAnterior().setVisible(false);
|
126 | 10603 | lmfernandez | } |
127 | return pSouth;
|
||
128 | } |
||
129 | 10609 | lmfernandez | public DefCrsUsr getPCrsUsr() {
|
130 | if(pCrsUsr==null){ |
||
131 | pCrsUsr=new DefCrsUsr();
|
||
132 | } |
||
133 | return pCrsUsr;
|
||
134 | } |
||
135 | public DefinirDatum getPDatum() {
|
||
136 | if(pDatum==null){ |
||
137 | pDatum=new DefinirDatum();
|
||
138 | } |
||
139 | return pDatum;
|
||
140 | } |
||
141 | public DefSistCoordenadas getPSistCoord() {
|
||
142 | if(pSistCoord==null){ |
||
143 | pSistCoord=new DefSistCoordenadas();
|
||
144 | } |
||
145 | return pSistCoord;
|
||
146 | } |
||
147 | 10603 | lmfernandez | public void actionPerformed(ActionEvent e) { |
148 | |||
149 | CardLayout cl = (CardLayout)(pCard.getLayout()); |
||
150 | |||
151 | if(e.getSource().equals(getBtnAnterior())){
|
||
152 | |||
153 | if(getPCrsUsr().isShowing()){
|
||
154 | 10786 | lmfernandez | //Se est? mostrando el primer panel del Wizard
|
155 | |||
156 | 10603 | lmfernandez | }else{
|
157 | //Mostrar el panel anterior
|
||
158 | cl.previous(pCard); |
||
159 | //Establecer los botones del Wizard
|
||
160 | getBtnFinalizar().setVisible(false);
|
||
161 | getBtnSiguiente().setVisible(true);
|
||
162 | 10786 | lmfernandez | |
163 | 10603 | lmfernandez | System.out.println("Dentro de botonAnterior"); |
164 | } |
||
165 | }else if(e.getSource().equals(getBtnSiguiente())){ |
||
166 | cl.next(pCard); |
||
167 | 10786 | lmfernandez | getBtnAnterior().setVisible(true);
|
168 | 10603 | lmfernandez | //Si aparece el ultimo panel visualizar el bot?n finalizar
|
169 | if (getPSistCoord().isShowing()){
|
||
170 | getBtnFinalizar().setVisible(true);
|
||
171 | getBtnSiguiente().setVisible(false);
|
||
172 | 10786 | lmfernandez | getBtnAnterior().setVisible(true);
|
173 | 10603 | lmfernandez | } |
174 | }else if(e.getSource().equals(getBtnFinalizar())){ |
||
175 | //Realizar las acciones de fin del Wizard
|
||
176 | System.out.println("Finalizar el Asistente"); |
||
177 | System.out.println("Cerrar el Asistente"); |
||
178 | 10786 | lmfernandez | PluginServices.getMDIManager().closeWindow(this);
|
179 | 10603 | lmfernandez | |
180 | }else if(e.getSource().equals(getBtnCancelar())){ |
||
181 | //Cerrar el asistente
|
||
182 | 10786 | lmfernandez | PluginServices.getMDIManager().closeWindow(this);
|
183 | 10603 | lmfernandez | } |
184 | } |
||
185 | 10786 | lmfernandez | public WindowInfo getWindowInfo() {
|
186 | WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
||
187 | 10787 | lmfernandez | m_viewinfo.setTitle(PluginServices.getText(this,"wz_titulo")); |
188 | 10786 | lmfernandez | m_viewinfo.setWidth(444);
|
189 | //m_viewinfo.setHeight(425);
|
||
190 | m_viewinfo.setHeight(390);
|
||
191 | return m_viewinfo;
|
||
192 | } |
||
193 | 10603 | lmfernandez | |
194 | 10609 | lmfernandez | |
195 | 10603 | lmfernandez | } |