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 @ 40596

History | View | Annotate | Download (6.94 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
package com.iver.cit.gvsig.gui;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.FlowLayout;
28

    
29
import javax.swing.DefaultListModel;
30
import javax.swing.JButton;
31
import javax.swing.JDialog;
32
import javax.swing.JFileChooser;
33
import javax.swing.JPanel;
34
import javax.swing.JTabbedPane;
35
import javax.swing.event.ChangeEvent;
36
import javax.swing.event.ChangeListener;
37

    
38
import org.cresques.cts.IProjection;
39

    
40
import com.iver.andami.PluginServices;
41
import com.iver.andami.ui.mdiManager.View;
42
import com.iver.andami.ui.mdiManager.ViewInfo;
43
import com.iver.cit.gvsig.gui.wizards.WizardListener;
44
import com.iver.cit.gvsig.project.Project;
45
/**
46
 * Di?logo para cargar las dieferentes capas a la vista.
47
 *
48
 * @author Vicente Caballero Navarro
49
 */
50
public class FOpenDialog extends JPanel implements com.iver.andami.ui.mdiManager.View {
51
        //private javax.swing.JDialog jDialog = null;  //  @jve:visual-info  decl-index=0 visual-constraint="19,27"
52
    
53
        static private IProjection proj = Project.getProjection();
54
        
55
        private javax.swing.JTabbedPane jTabbedPane = null;
56
    private javax.swing.JPanel psegundo = null;
57
    private DefaultListModel m_lstModel;
58
    private JFileChooser fileChooser;
59

    
60
        private JPanel jPanel = null;
61
        private JButton btnAceptar = null;
62
        private JButton jButton = null;
63
        
64
        private boolean accepted = false;
65
        
66
        private WizardListener wizardListener = new DialogWizardListener();
67
    /**
68
     * Creates a new FOpenDialog object.
69
     *
70
     * @param view Vista que vamos a refrescar
71
     * @param mapControl MapControl que recibe la capa (te puede interesar
72
     *        a?adirla al principal o al Overview.
73
     */
74
    public FOpenDialog() {
75
            initialize();
76
            
77
        // Cada vez que se abre, se borran las capas que pudiera haber.
78
        m_lstModel = new DefaultListModel(); 
79
    }
80

    
81
    /**
82
     * This method initializes this
83
     */
84
    private void initialize() {
85
        this.setLayout(new BorderLayout());
86
        this.setSize(523, 385);
87
        this.setPreferredSize(new java.awt.Dimension(523, 385));
88
        this.add(getJTabbedPane(), BorderLayout.CENTER);
89
        this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
90
    }
91

    
92
    /**
93
     * This method initializes jTabbedPane
94
     *
95
     * @return javax.swing.JTabbedPane
96
     */
97
    private javax.swing.JTabbedPane getJTabbedPane() {
98
        if (jTabbedPane == null) {
99
            jTabbedPane = new javax.swing.JTabbedPane();
100
            jTabbedPane.setBounds(0, 0, getViewInfo().getWidth()-10, getViewInfo().getHeight()-10);
101
            jTabbedPane.addChangeListener(new ChangeListener() {
102
                                public void stateChanged(ChangeEvent e) {
103
                                        JTabbedPane tabs = (JTabbedPane) e.getSource();
104
                                        getBtnAceptar().setEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
105
                                }
106
                        });
107
        }
108

    
109
        return jTabbedPane;
110
    }
111

    
112
    public void addTab(String title, JPanel panel){
113
            getJTabbedPane().addTab(title, panel);
114
    }
115
    
116
    public void addWizardTab(String title, WizardPanel panel){
117
            panel.addWizardListener(wizardListener);
118
            getJTabbedPane().addTab(title, panel);
119
    }
120
    
121
    public JPanel getSelectedTab(){
122
            return (JPanel) getJTabbedPane().getSelectedComponent();
123
    }
124
    
125
    public ViewInfo getViewInfo() {
126
            ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
127
                   m_viewinfo.setTitle(PluginServices.getText(this,"Abrir_una_capa"));
128
                    m_viewinfo.setHeight(500);
129
                    m_viewinfo.setWidth(520);
130
        return m_viewinfo;
131
    }
132

    
133
        /**
134
         * This method initializes jPanel        
135
         *         
136
         * @return javax.swing.JPanel        
137
         */    
138
        private JPanel getJPanel() {
139
                if (jPanel == null) {
140
                        FlowLayout flowLayout1 = new FlowLayout();
141
                        jPanel = new JPanel();
142
                        jPanel.setLayout(flowLayout1);
143
                        flowLayout1.setHgap(30);
144
                        jPanel.add(getBtnAceptar(), null);
145
                        jPanel.add(getJButton(), null);
146
                }
147
                return jPanel;
148
        }
149
        /**
150
         * This method initializes btnAceptar        
151
         *         
152
         * @return javax.swing.JButton        
153
         */    
154
        private JButton getBtnAceptar() {
155
                if (btnAceptar == null) {
156
                        btnAceptar = new JButton();
157
                        btnAceptar.setText(PluginServices.getText(this,"Aceptar"));
158
                        btnAceptar.addActionListener(new java.awt.event.ActionListener() { 
159
                                public void actionPerformed(java.awt.event.ActionEvent e) {
160
                                        accepted = true;
161
                    if (PluginServices.getMainFrame() == null) {
162
                        ((JDialog) (getParent().getParent().getParent()
163
                                .getParent())).dispose();
164
                    } else {
165
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
166
                    }
167
                                }
168
                        });
169
                }
170
                return btnAceptar;
171
        }
172
        /**
173
         * This method initializes jButton        
174
         *         
175
         * @return javax.swing.JButton        
176
         */    
177
        private JButton getJButton() {
178
                if (jButton == null) {
179
                        jButton = new JButton();
180
                        jButton.setText(PluginServices.getText(this,"Cancelar"));
181
                        jButton.addActionListener(new java.awt.event.ActionListener() { 
182
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
183
                    if (PluginServices.getMainFrame() != null) {
184
                        PluginServices.getMDIManager().closeView((View) FOpenDialog.this);
185
                    } else {
186
                        ((JDialog) (getParent().getParent().getParent()
187
                                        .getParent())).dispose();
188
                    }
189
                                }
190
                        });
191
                }
192
                return jButton;
193
        }
194
        public boolean isAccepted() {
195
                return accepted;
196
        }
197
        
198
        public class DialogWizardListener implements WizardListener {
199

    
200
                /**
201
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
202
                 */
203
                public void error(Exception e) {
204
                }
205

    
206
                /**
207
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
208
                 */
209
                public void wizardStateChanged(boolean finishable) {
210
                        getBtnAceptar().setEnabled(finishable);
211
                }
212
                
213
        }
214
        public static IProjection getLastProjection() {
215
                return proj;
216
        }
217
        public static void setLastProjection(IProjection proj) {
218
                FOpenDialog.proj = proj;
219
        }
220
   }  //  @jve:decl-index=0:visual-constraint="10,10"
221
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
222
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"