Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.i18n / src / test / data / src / appgvSIG / com / iver / cit / gvsig / gui / FOpenDialog.java @ 40559

History | View | Annotate | Download (8.3 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * Created on 23-abr-2004
26
 *
27
 * To change the template for this generated file go to
28
 * Window>Preferences>Java>Code Generation>Code and Comments
29
 */
30
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
31
 *
32
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
33
 *
34
 * This program is free software; you can redistribute it and/or
35
 * modify it under the terms of the GNU General Public License
36
 * as published by the Free Software Foundation; either version 2
37
 * of the License, or (at your option) any later version.
38
 *
39
 * This program is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42
 * GNU General Public License for more details.
43
 *
44
 * You should have received a copy of the GNU General Public License
45
 * along with this program; if not, write to the Free Software
46
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
47
 *
48
 * For more information, contact:
49
 *
50
 *  Generalitat Valenciana
51
 *   Conselleria d'Infraestructures i Transport
52
 *   Av. Blasco Ib??ez, 50
53
 *   46010 VALENCIA
54
 *   SPAIN
55
 *
56
 *      +34 963862235
57
 *   gvsig@gva.es
58
 *      www.gvsig.gva.es
59
 *
60
 *    or
61
 *
62
 *   IVER T.I. S.A
63
 *   Salamanca 50
64
 *   46005 Valencia
65
 *   Spain
66
 *
67
 *   +34 963163400
68
 *   dac@iver.es
69
 */
70
package com.iver.cit.gvsig.gui;
71

    
72
import java.awt.BorderLayout;
73
import java.awt.FlowLayout;
74

    
75
import javax.swing.DefaultListModel;
76
import javax.swing.JButton;
77
import javax.swing.JDialog;
78
import javax.swing.JFileChooser;
79
import javax.swing.JPanel;
80
import javax.swing.JTabbedPane;
81
import javax.swing.event.ChangeEvent;
82
import javax.swing.event.ChangeListener;
83

    
84
import org.cresques.cts.IProjection;
85

    
86
import com.iver.andami.PluginServices;
87
import com.iver.andami.ui.mdiManager.View;
88
import com.iver.andami.ui.mdiManager.ViewInfo;
89
import com.iver.cit.gvsig.gui.wizards.WizardListener;
90
import com.iver.cit.gvsig.project.Project;
91
/**
92
 * Di?logo para cargar las dieferentes capas a la vista.
93
 *
94
 * @author Vicente Caballero Navarro
95
 */
96
public class FOpenDialog extends JPanel implements com.iver.andami.ui.mdiManager.View {
97
        //private javax.swing.JDialog jDialog = null;  //  @jve:visual-info  decl-index=0 visual-constraint="19,27"
98
    
99
        static private IProjection proj = Project.getProjection();
100
        
101
        private javax.swing.JTabbedPane jTabbedPane = null;
102
    private javax.swing.JPanel psegundo = null;
103
    private DefaultListModel m_lstModel;
104
    private JFileChooser fileChooser;
105

    
106
        private JPanel jPanel = null;
107
        private JButton btnAceptar = null;
108
        private JButton jButton = null;
109
        
110
        private boolean accepted = false;
111
        
112
        private WizardListener wizardListener = new DialogWizardListener();
113
    /**
114
     * Creates a new FOpenDialog object.
115
     *
116
     * @param view Vista que vamos a refrescar
117
     * @param mapControl MapControl que recibe la capa (te puede interesar
118
     *        a?adirla al principal o al Overview.
119
     */
120
    public FOpenDialog() {
121
            initialize();
122
            
123
        // Cada vez que se abre, se borran las capas que pudiera haber.
124
        m_lstModel = new DefaultListModel(); 
125
    }
126

    
127
    /**
128
     * This method initializes this
129
     */
130
    private void initialize() {
131
        this.setLayout(new BorderLayout());
132
        this.setSize(523, 385);
133
        this.setPreferredSize(new java.awt.Dimension(523, 385));
134
        this.add(getJTabbedPane(), BorderLayout.CENTER);
135
        this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
136
    }
137

    
138
    /**
139
     * This method initializes jTabbedPane
140
     *
141
     * @return javax.swing.JTabbedPane
142
     */
143
    private javax.swing.JTabbedPane getJTabbedPane() {
144
        if (jTabbedPane == null) {
145
            jTabbedPane = new javax.swing.JTabbedPane();
146
            jTabbedPane.setBounds(0, 0, getViewInfo().getWidth()-10, getViewInfo().getHeight()-10);
147
            jTabbedPane.addChangeListener(new ChangeListener() {
148
                                public void stateChanged(ChangeEvent e) {
149
                                        JTabbedPane tabs = (JTabbedPane) e.getSource();
150
                                        getBtnAceptar().setEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
151
                                }
152
                        });
153
        }
154

    
155
        return jTabbedPane;
156
    }
157

    
158
    public void addTab(String title, JPanel panel){
159
            getJTabbedPane().addTab(title, panel);
160
    }
161
    
162
    public void addWizardTab(String title, WizardPanel panel){
163
            panel.addWizardListener(wizardListener);
164
            getJTabbedPane().addTab(title, panel);
165
    }
166
    
167
    public JPanel getSelectedTab(){
168
            return (JPanel) getJTabbedPane().getSelectedComponent();
169
    }
170
    
171
    public ViewInfo getViewInfo() {
172
            ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
173
                   m_viewinfo.setTitle(PluginServices.getText(this,"Abrir_una_capa"));
174
                    m_viewinfo.setHeight(500);
175
                    m_viewinfo.setWidth(520);
176
        return m_viewinfo;
177
    }
178

    
179
        /**
180
         * This method initializes jPanel        
181
         *         
182
         * @return javax.swing.JPanel        
183
         */    
184
        private JPanel getJPanel() {
185
                if (jPanel == null) {
186
                        FlowLayout flowLayout1 = new FlowLayout();
187
                        jPanel = new JPanel();
188
                        jPanel.setLayout(flowLayout1);
189
                        flowLayout1.setHgap(30);
190
                        jPanel.add(getBtnAceptar(), null);
191
                        jPanel.add(getJButton(), null);
192
                }
193
                return jPanel;
194
        }
195
        /**
196
         * This method initializes btnAceptar        
197
         *         
198
         * @return javax.swing.JButton        
199
         */    
200
        private JButton getBtnAceptar() {
201
                if (btnAceptar == null) {
202
                        btnAceptar = new JButton();
203
                        btnAceptar.setText(PluginServices.getText(this,"Aceptar"));
204
                        btnAceptar.addActionListener(new java.awt.event.ActionListener() { 
205
                                public void actionPerformed(java.awt.event.ActionEvent e) {
206
                                        accepted = true;
207
                    if (PluginServices.getMainFrame() == null) {
208
                        ((JDialog) (getParent().getParent().getParent()
209
                                .getParent())).dispose();
210
                    } else {
211
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
212
                    }
213
                                }
214
                        });
215
                }
216
                return btnAceptar;
217
        }
218
        /**
219
         * This method initializes jButton        
220
         *         
221
         * @return javax.swing.JButton        
222
         */    
223
        private JButton getJButton() {
224
                if (jButton == null) {
225
                        jButton = new JButton();
226
                        jButton.setText(PluginServices.getText(this,"Cancelar"));
227
                        jButton.addActionListener(new java.awt.event.ActionListener() { 
228
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
229
                    if (PluginServices.getMainFrame() != null) {
230
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
231
                    } else {
232
                        ((JDialog) (getParent().getParent().getParent()
233
                                        .getParent())).dispose();
234
                    }
235
                                }
236
                        });
237
                }
238
                return jButton;
239
        }
240
        public boolean isAccepted() {
241
                return accepted;
242
        }
243
        
244
        public class DialogWizardListener implements WizardListener {
245

    
246
                /**
247
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
248
                 */
249
                public void error(Exception e) {
250
                }
251

    
252
                /**
253
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
254
                 */
255
                public void wizardStateChanged(boolean finishable) {
256
                        getBtnAceptar().setEnabled(finishable);
257
                }
258
                
259
        }
260
        public static IProjection getLastProjection() {
261
                return proj;
262
        }
263
        public static void setLastProjection(IProjection proj) {
264
                FOpenDialog.proj = proj;
265
        }
266
   }  //  @jve:decl-index=0:visual-constraint="10,10"
267
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
268
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"