Statistics
| Revision:

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

History | View | Annotate | Download (7.24 KB)

1
/*
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
/* 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
package com.iver.cit.gvsig.gui;
48

    
49
import java.awt.BorderLayout;
50
import java.awt.FlowLayout;
51

    
52
import javax.swing.DefaultListModel;
53
import javax.swing.JButton;
54
import javax.swing.JDialog;
55
import javax.swing.JFileChooser;
56
import javax.swing.JPanel;
57
import javax.swing.JTabbedPane;
58
import javax.swing.event.ChangeEvent;
59
import javax.swing.event.ChangeListener;
60

    
61
import org.cresques.cts.IProjection;
62

    
63
import com.iver.andami.PluginServices;
64
import com.iver.andami.ui.mdiManager.View;
65
import com.iver.andami.ui.mdiManager.ViewInfo;
66
import com.iver.cit.gvsig.gui.wms.WizardListener;
67
import com.iver.cit.gvsig.project.Project;
68
/**
69
 * Di?logo para cargar las dieferentes capas a la vista.
70
 *
71
 * @author Vicente Caballero Navarro
72
 */
73
public class FOpenDialog extends JPanel implements com.iver.andami.ui.mdiManager.View {
74
        //private javax.swing.JDialog jDialog = null;  //  @jve:visual-info  decl-index=0 visual-constraint="19,27"
75
    
76
        static private IProjection proj = Project.getProjection();
77
        
78
        private javax.swing.JTabbedPane jTabbedPane = null;
79
    private javax.swing.JPanel psegundo = null;
80
    private DefaultListModel m_lstModel;
81
    private JFileChooser fileChooser;
82

    
83
        private JPanel jPanel = null;
84
        private JButton btnAceptar = null;
85
        private JButton jButton = null;
86
        
87
        private boolean accepted = false;
88
        
89
        private WizardListener wizardListener = new DialogWizardListener();
90
    /**
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
    public FOpenDialog() {
98
            initialize();
99
            
100
        // 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
        this.setLayout(new BorderLayout());
109
        this.setSize(523, 385);
110
        this.setPreferredSize(new java.awt.Dimension(523, 385));
111
        this.add(getJTabbedPane(), BorderLayout.CENTER);
112
        this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
113
    }
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
            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
        }
131

    
132
        return jTabbedPane;
133
    }
134

    
135
    public void addTab(String title, JPanel panel){
136
            getJTabbedPane().addTab(title, panel);
137
    }
138
    
139
    public void addWizardTab(String title, WizardPanel panel){
140
            panel.addWizardListener(wizardListener);
141
            getJTabbedPane().addTab(title, panel);
142
    }
143
    
144
    public JPanel getSelectedTab(){
145
            return (JPanel) getJTabbedPane().getSelectedComponent();
146
    }
147
    
148
    public ViewInfo getViewInfo() {
149
            ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
150
                   m_viewinfo.setTitle(PluginServices.getText(this,"Abrir_una_capa"));
151
        return m_viewinfo;
152
    }
153

    
154
        /**
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
                        btnAceptar.setText(PluginServices.getText(this,"Aceptar"));
179
                        btnAceptar.addActionListener(new java.awt.event.ActionListener() { 
180
                                public void actionPerformed(java.awt.event.ActionEvent e) {
181
                                        accepted = true;
182
                    if (PluginServices.getMainFrame() == null) {
183
                        ((JDialog) (getParent().getParent().getParent()
184
                                .getParent())).dispose();
185
                    } else {
186
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
187
                    }
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
                        jButton.setText(PluginServices.getText(this,"Cancelar"));
202
                        jButton.addActionListener(new java.awt.event.ActionListener() { 
203
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
204
                    if (PluginServices.getMainFrame() != null) {
205
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
206
                    } 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
        
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
        public static IProjection getLastProjection() {
236
                return proj;
237
        }
238
        public static void setLastProjection(IProjection proj) {
239
                FOpenDialog.proj = proj;
240
        }
241
   }  //  @jve:decl-index=0:visual-constraint="10,10"
242
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
243
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"