Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FOpenDialog.java @ 2645

History | View | Annotate | Download (7.25 KB)

1 312 fernando
/*
2
 * Created on 23-abr-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7 1103 fjp
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47 312 fernando
package com.iver.cit.gvsig.gui;
48
49 596 fernando
import java.awt.BorderLayout;
50
import java.awt.FlowLayout;
51 312 fernando
52
import javax.swing.DefaultListModel;
53 596 fernando
import javax.swing.JButton;
54 437 fernando
import javax.swing.JDialog;
55 312 fernando
import javax.swing.JFileChooser;
56
import javax.swing.JPanel;
57 858 fernando
import javax.swing.JTabbedPane;
58
import javax.swing.event.ChangeEvent;
59
import javax.swing.event.ChangeListener;
60 312 fernando
61 904 fjp
import org.cresques.cts.IProjection;
62
63 596 fernando
import com.iver.andami.PluginServices;
64
import com.iver.andami.ui.mdiManager.View;
65
import com.iver.andami.ui.mdiManager.ViewInfo;
66 2277 vcaballero
import com.iver.cit.gvsig.gui.wizards.WizardListener;
67 1221 fernando
import com.iver.cit.gvsig.project.Project;
68 312 fernando
/**
69
 * Di?logo para cargar las dieferentes capas a la vista.
70
 *
71
 * @author Vicente Caballero Navarro
72
 */
73 596 fernando
public class FOpenDialog extends JPanel implements com.iver.andami.ui.mdiManager.View {
74 428 fernando
        //private javax.swing.JDialog jDialog = null;  //  @jve:visual-info  decl-index=0 visual-constraint="19,27"
75 904 fjp
76
        static private IProjection proj = Project.getProjection();
77
78
        private javax.swing.JTabbedPane jTabbedPane = null;
79 312 fernando
    private javax.swing.JPanel psegundo = null;
80
    private DefaultListModel m_lstModel;
81 411 fernando
    private JFileChooser fileChooser;
82 312 fernando
83 437 fernando
        private JPanel jPanel = null;
84
        private JButton btnAceptar = null;
85
        private JButton jButton = null;
86
87
        private boolean accepted = false;
88 858 fernando
89
        private WizardListener wizardListener = new DialogWizardListener();
90 312 fernando
    /**
91
     * Creates a new FOpenDialog object.
92
     *
93
     * @param view Vista que vamos a refrescar
94
     * @param mapControl MapControl que recibe la capa (te puede interesar
95
     *        a?adirla al principal o al Overview.
96
     */
97 357 fjp
    public FOpenDialog() {
98 428 fernando
            initialize();
99
100 312 fernando
        // Cada vez que se abre, se borran las capas que pudiera haber.
101
        m_lstModel = new DefaultListModel();
102
    }
103
104
    /**
105
     * This method initializes this
106
     */
107
    private void initialize() {
108 428 fernando
        this.setLayout(new BorderLayout());
109 2183 fernando
        this.setSize(523, 385);
110
        this.setPreferredSize(new java.awt.Dimension(523, 385));
111 428 fernando
        this.add(getJTabbedPane(), BorderLayout.CENTER);
112 437 fernando
        this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
113 312 fernando
    }
114
115
    /**
116
     * This method initializes jTabbedPane
117
     *
118
     * @return javax.swing.JTabbedPane
119
     */
120
    private javax.swing.JTabbedPane getJTabbedPane() {
121
        if (jTabbedPane == null) {
122
            jTabbedPane = new javax.swing.JTabbedPane();
123
            jTabbedPane.setBounds(0, 0, 519, 352);
124 858 fernando
            jTabbedPane.addChangeListener(new ChangeListener() {
125
                                public void stateChanged(ChangeEvent e) {
126
                                        JTabbedPane tabs = (JTabbedPane) e.getSource();
127
                                        getBtnAceptar().setEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
128
                                }
129
                        });
130 312 fernando
        }
131
132
        return jTabbedPane;
133
    }
134
135 428 fernando
    public void addTab(String title, JPanel panel){
136
            getJTabbedPane().addTab(title, panel);
137 312 fernando
    }
138 428 fernando
139 858 fernando
    public void addWizardTab(String title, WizardPanel panel){
140
            panel.addWizardListener(wizardListener);
141
            getJTabbedPane().addTab(title, panel);
142
    }
143
144 428 fernando
    public JPanel getSelectedTab(){
145
            return (JPanel) getJTabbedPane().getSelectedComponent();
146 312 fernando
    }
147 428 fernando
148 312 fernando
    public ViewInfo getViewInfo() {
149 596 fernando
            ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
150
                   m_viewinfo.setTitle(PluginServices.getText(this,"Abrir_una_capa"));
151 312 fernando
        return m_viewinfo;
152
    }
153
154 437 fernando
        /**
155
         * This method initializes jPanel
156
         *
157
         * @return javax.swing.JPanel
158
         */
159
        private JPanel getJPanel() {
160
                if (jPanel == null) {
161
                        FlowLayout flowLayout1 = new FlowLayout();
162
                        jPanel = new JPanel();
163
                        jPanel.setLayout(flowLayout1);
164
                        flowLayout1.setHgap(30);
165
                        jPanel.add(getBtnAceptar(), null);
166
                        jPanel.add(getJButton(), null);
167
                }
168
                return jPanel;
169
        }
170
        /**
171
         * This method initializes btnAceptar
172
         *
173
         * @return javax.swing.JButton
174
         */
175
        private JButton getBtnAceptar() {
176
                if (btnAceptar == null) {
177
                        btnAceptar = new JButton();
178 1500 fjp
                        btnAceptar.setText(PluginServices.getText(this,"Aceptar"));
179 437 fernando
                        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
180
                                public void actionPerformed(java.awt.event.ActionEvent e) {
181
                                        accepted = true;
182 600 fjp
                    if (PluginServices.getMainFrame() == null) {
183 437 fernando
                        ((JDialog) (getParent().getParent().getParent()
184
                                .getParent())).dispose();
185
                    } else {
186 596 fernando
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
187 437 fernando
                    }
188
                                }
189
                        });
190
                }
191
                return btnAceptar;
192
        }
193
        /**
194
         * This method initializes jButton
195
         *
196
         * @return javax.swing.JButton
197
         */
198
        private JButton getJButton() {
199
                if (jButton == null) {
200
                        jButton = new JButton();
201 1500 fjp
                        jButton.setText(PluginServices.getText(this,"Cancelar"));
202 437 fernando
                        jButton.addActionListener(new java.awt.event.ActionListener() {
203
                                public void actionPerformed(java.awt.event.ActionEvent e) {
204 1115 fjp
                    if (PluginServices.getMainFrame() != null) {
205 596 fernando
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
206 437 fernando
                    } else {
207
                        ((JDialog) (getParent().getParent().getParent()
208
                                        .getParent())).dispose();
209
                    }
210
                                }
211
                        });
212
                }
213
                return jButton;
214
        }
215
        public boolean isAccepted() {
216
                return accepted;
217
        }
218 858 fernando
219
        public class DialogWizardListener implements WizardListener {
220
221
                /**
222
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
223
                 */
224
                public void error(Exception e) {
225
                }
226
227
                /**
228
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
229
                 */
230
                public void wizardStateChanged(boolean finishable) {
231
                        getBtnAceptar().setEnabled(finishable);
232
                }
233
234
        }
235 904 fjp
        public static IProjection getLastProjection() {
236
                return proj;
237
        }
238
        public static void setLastProjection(IProjection proj) {
239
                FOpenDialog.proj = proj;
240
        }
241 437 fernando
   }  //  @jve:decl-index=0:visual-constraint="10,10"
242 312 fernando
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
243
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"