Statistics
| Revision:

svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FOpenDialog.java @ 5222

History | View | Annotate | Download (7.37 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.wizards.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, getViewInfo().getWidth()-10, getViewInfo().getHeight()-10);
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
        m_viewinfo.setHeight(500);
152
        m_viewinfo.setWidth(520);
153
        return m_viewinfo;
154
    }
155

    
156
        /**
157
         * This method initializes jPanel        
158
         *         
159
         * @return javax.swing.JPanel        
160
         */    
161
        private JPanel getJPanel() {
162
                if (jPanel == null) {
163
                        FlowLayout flowLayout1 = new FlowLayout();
164
                        jPanel = new JPanel();
165
                        jPanel.setLayout(flowLayout1);
166
                        flowLayout1.setHgap(30);
167
                        jPanel.add(getBtnAceptar(), null);
168
                        jPanel.add(getJButton(), null);
169
                }
170
                return jPanel;
171
        }
172
        /**
173
         * This method initializes btnAceptar        
174
         *         
175
         * @return javax.swing.JButton        
176
         */    
177
        private JButton getBtnAceptar() {
178
                if (btnAceptar == null) {
179
                        btnAceptar = new JButton();
180
                        btnAceptar.setText(PluginServices.getText(this,"Aceptar"));
181
                        btnAceptar.addActionListener(new java.awt.event.ActionListener() { 
182
                                public void actionPerformed(java.awt.event.ActionEvent e) {
183
                                        accepted = true;
184
                    if (PluginServices.getMainFrame() == null) {
185
                        ((JDialog) (getParent().getParent().getParent()
186
                                .getParent())).dispose();
187
                    } else {
188
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
189
                    }
190
                                }
191
                        });
192
                }
193
                return btnAceptar;
194
        }
195
        /**
196
         * This method initializes jButton        
197
         *         
198
         * @return javax.swing.JButton        
199
         */    
200
        private JButton getJButton() {
201
                if (jButton == null) {
202
                        jButton = new JButton();
203
                        jButton.setText(PluginServices.getText(this,"Cancelar"));
204
                        jButton.addActionListener(new java.awt.event.ActionListener() { 
205
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
206
                    if (PluginServices.getMainFrame() != null) {
207
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
208
                    } else {
209
                        ((JDialog) (getParent().getParent().getParent()
210
                                        .getParent())).dispose();
211
                    }
212
                                }
213
                        });
214
                }
215
                return jButton;
216
        }
217
        public boolean isAccepted() {
218
                return accepted;
219
        }
220
        
221
        public class DialogWizardListener implements WizardListener {
222

    
223
                /**
224
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
225
                 */
226
                public void error(Exception e) {
227
                }
228

    
229
                /**
230
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
231
                 */
232
                public void wizardStateChanged(boolean finishable) {
233
                        getBtnAceptar().setEnabled(finishable);
234
                }
235
                
236
        }
237
        public static IProjection getLastProjection() {
238
                return proj;
239
        }
240
        public static void setLastProjection(IProjection proj) {
241
                FOpenDialog.proj = proj;
242
        }
243
   }  //  @jve:decl-index=0:visual-constraint="10,10"
244
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
245
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"