Statistics
| Revision:

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

History | View | Annotate | Download (6.49 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.event.ActionListener;
51

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

    
59
import org.cresques.cts.IProjection;
60
import org.gvsig.gui.beans.AcceptCancelPanel;
61

    
62
import com.iver.andami.PluginServices;
63
import com.iver.andami.ui.mdiManager.IWindow;
64
import com.iver.andami.ui.mdiManager.WindowInfo;
65
import com.iver.cit.gvsig.gui.wizards.WizardListener;
66
import com.iver.cit.gvsig.project.Project;
67
/**
68
 * Di?logo para cargar las dieferentes capas a la vista.
69
 *
70
 * @author Vicente Caballero Navarro
71
 */
72
public class FOpenDialog extends JPanel implements com.iver.andami.ui.mdiManager.IWindow {
73

    
74
        static private IProjection proj;
75

    
76
        private javax.swing.JTabbedPane jTabbedPane = null;
77

    
78
        private AcceptCancelPanel jPanel = null;
79

    
80
        private boolean accepted = false;
81

    
82
        private String title = PluginServices.getText(this,"Abrir_una_capa");
83

    
84
        private WizardListener wizardListener = new DialogWizardListener();
85
    /**
86
     * Creates a new FOpenDialog object.
87
     *
88
     * @param view Vista que vamos a refrescar
89
     * @param mapControl MapControl que recibe la capa (te puede interesar
90
     *        a?adirla al principal o al Overview.
91
     */
92
    public FOpenDialog() {
93
            initialize();
94
    }
95

    
96
    public FOpenDialog(String title) {
97
            this.title = title;
98
            initialize();
99
    }
100

    
101
    /**
102
     * This method initializes this
103
     */
104
    private void initialize() {
105
        this.setLayout(new BorderLayout());
106
        this.setSize(523, 385);
107
        this.setPreferredSize(new java.awt.Dimension(523, 385));
108
        this.add(getJTabbedPane(), BorderLayout.CENTER);
109
        this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
110
    }
111

    
112
    /**
113
     * This method initializes jTabbedPane
114
     *
115
     * @return javax.swing.JTabbedPane
116
     */
117
    private javax.swing.JTabbedPane getJTabbedPane() {
118
        if (jTabbedPane == null) {
119
            jTabbedPane = new javax.swing.JTabbedPane();
120
            jTabbedPane.setBounds(0, 0, getWindowInfo().getWidth()-10, getWindowInfo().getHeight()-10);
121
            jTabbedPane.addChangeListener(new ChangeListener() {
122
                                public void stateChanged(ChangeEvent e) {
123
                                        JTabbedPane tabs = (JTabbedPane) e.getSource();
124
                                        getJPanel().setOkButtonEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
125
                                }
126
                        });
127
        }
128

    
129
        return jTabbedPane;
130
    }
131

    
132
    public void addTab(String title, JPanel panel){
133
            getJTabbedPane().addTab(title, panel);
134
    }
135

    
136
    public void addWizardTab(String title, WizardPanel panel){
137
            panel.addWizardListener(wizardListener);
138
            getJTabbedPane().addTab(title, panel);
139
    }
140

    
141
    public JPanel getSelectedTab(){
142
            return (JPanel) getJTabbedPane().getSelectedComponent();
143
    }
144

    
145
    public WindowInfo getWindowInfo() {
146
            WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
147
                   m_viewinfo.setTitle(this.title);
148
                    m_viewinfo.setHeight(500);
149
                    m_viewinfo.setWidth(520);
150
        return m_viewinfo;
151
    }
152

    
153
        /**
154
         * This method initializes jPanel
155
         *
156
         * @return javax.swing.JPanel
157
         */
158
        private AcceptCancelPanel getJPanel() {
159
                if (jPanel == null) {
160
                        ActionListener okAction = new java.awt.event.ActionListener() {
161
                                public void actionPerformed(java.awt.event.ActionEvent e) {
162
                                        accepted = true;
163
                    if (PluginServices.getMainFrame() == null) {
164
                        ((JDialog) (getParent().getParent().getParent()
165
                                .getParent())).dispose();
166
                    } else {
167
                        PluginServices.getMDIManager().closeWindow((IWindow) FOpenDialog.this);
168
                    }
169
                                }
170
                        };
171
                        ActionListener cancelAction = new java.awt.event.ActionListener() {
172
                                public void actionPerformed(java.awt.event.ActionEvent e) {
173
                    if (PluginServices.getMainFrame() != null) {
174
                        PluginServices.getMDIManager().closeWindow((IWindow) FOpenDialog.this);
175
                    } else {
176
                        ((JDialog) (getParent().getParent().getParent()
177
                                        .getParent())).dispose();
178
                    }
179
                                }
180
                        };
181
                        jPanel = new AcceptCancelPanel(okAction, cancelAction);
182
                }
183
                return jPanel;
184
        }
185

    
186

    
187
        public boolean isAccepted() {
188
                return accepted;
189
        }
190

    
191
        public class DialogWizardListener implements WizardListener {
192

    
193
                /**
194
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#error(java.lang.Exception)
195
                 */
196
                public void error(Exception e) {
197
                }
198

    
199
                /**
200
                 * @see com.iver.cit.gvsig.gui.wms.WizardListener#wizardStateChanged(boolean)
201
                 */
202
                public void wizardStateChanged(boolean finishable) {
203
                        getJPanel().setOkButtonEnabled(finishable);
204
                }
205

    
206
        }
207
        public static IProjection getLastProjection() {
208
                // no entiendo porqu? se necesita esto aqu?...
209
                if (proj == null)
210
                        proj = Project.getDefaultProjection();
211
                return proj;
212
        }
213

    
214
        public static void setLastProjection(IProjection proj) {
215
                FOpenDialog.proj = proj;
216
        }
217
   }  //  @jve:decl-index=0:visual-constraint="10,10"
218
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
219
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"