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 | 312 | fernando | /*
|
---|---|---|---|
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 | 1103 | fjp | /* 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 | 312 | fernando | package com.iver.cit.gvsig.gui; |
48 | |||
49 | 596 | fernando | import java.awt.BorderLayout; |
50 | 6122 | jaume | import java.awt.event.ActionListener; |
51 | 312 | fernando | |
52 | 596 | fernando | import javax.swing.JButton; |
53 | 437 | fernando | import javax.swing.JDialog; |
54 | 312 | fernando | import javax.swing.JPanel; |
55 | 858 | fernando | import javax.swing.JTabbedPane; |
56 | import javax.swing.event.ChangeEvent; |
||
57 | import javax.swing.event.ChangeListener; |
||
58 | 312 | fernando | |
59 | 904 | fjp | import org.cresques.cts.IProjection; |
60 | 6122 | jaume | import org.gvsig.gui.beans.AcceptCancelPanel; |
61 | 904 | fjp | |
62 | 596 | fernando | import com.iver.andami.PluginServices; |
63 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
64 | 6880 | cesar | import com.iver.andami.ui.mdiManager.WindowInfo; |
65 | 2277 | vcaballero | import com.iver.cit.gvsig.gui.wizards.WizardListener; |
66 | 1221 | fernando | import com.iver.cit.gvsig.project.Project; |
67 | 312 | fernando | /**
|
68 | * Di?logo para cargar las dieferentes capas a la vista.
|
||
69 | *
|
||
70 | * @author Vicente Caballero Navarro
|
||
71 | */
|
||
72 | 6877 | cesar | public class FOpenDialog extends JPanel implements com.iver.andami.ui.mdiManager.IWindow { |
73 | 6122 | jaume | |
74 | 7287 | jaume | static private IProjection proj; |
75 | 6122 | jaume | |
76 | 904 | fjp | private javax.swing.JTabbedPane jTabbedPane = null; |
77 | 312 | fernando | |
78 | 6122 | jaume | private AcceptCancelPanel jPanel = null; |
79 | |||
80 | 437 | fernando | private boolean accepted = false; |
81 | 7287 | jaume | |
82 | 6230 | jmvivo | private String title = PluginServices.getText(this,"Abrir_una_capa"); |
83 | 6122 | jaume | |
84 | 858 | fernando | private WizardListener wizardListener = new DialogWizardListener(); |
85 | 312 | fernando | /**
|
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 | 357 | fjp | public FOpenDialog() {
|
93 | 428 | fernando | initialize(); |
94 | 312 | fernando | } |
95 | |||
96 | 6230 | jmvivo | public FOpenDialog(String title) { |
97 | this.title = title;
|
||
98 | initialize(); |
||
99 | } |
||
100 | |||
101 | 312 | fernando | /**
|
102 | * This method initializes this
|
||
103 | */
|
||
104 | private void initialize() { |
||
105 | 428 | fernando | this.setLayout(new BorderLayout()); |
106 | 2183 | fernando | this.setSize(523, 385); |
107 | this.setPreferredSize(new java.awt.Dimension(523, 385)); |
||
108 | 428 | fernando | this.add(getJTabbedPane(), BorderLayout.CENTER); |
109 | 437 | fernando | this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
|
110 | 312 | fernando | } |
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 | 6880 | cesar | jTabbedPane.setBounds(0, 0, getWindowInfo().getWidth()-10, getWindowInfo().getHeight()-10); |
121 | 858 | fernando | jTabbedPane.addChangeListener(new ChangeListener() { |
122 | public void stateChanged(ChangeEvent e) { |
||
123 | JTabbedPane tabs = (JTabbedPane) e.getSource(); |
||
124 | 6122 | jaume | getJPanel().setOkButtonEnabled(!(tabs.getSelectedComponent() instanceof WizardPanel));
|
125 | 858 | fernando | } |
126 | }); |
||
127 | 312 | fernando | } |
128 | |||
129 | return jTabbedPane;
|
||
130 | } |
||
131 | |||
132 | 428 | fernando | public void addTab(String title, JPanel panel){ |
133 | getJTabbedPane().addTab(title, panel); |
||
134 | 312 | fernando | } |
135 | 6122 | jaume | |
136 | 858 | fernando | public void addWizardTab(String title, WizardPanel panel){ |
137 | panel.addWizardListener(wizardListener); |
||
138 | getJTabbedPane().addTab(title, panel); |
||
139 | } |
||
140 | 6122 | jaume | |
141 | 428 | fernando | public JPanel getSelectedTab(){ |
142 | return (JPanel) getJTabbedPane().getSelectedComponent(); |
||
143 | 312 | fernando | } |
144 | 6122 | jaume | |
145 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
146 | WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
||
147 | 6230 | jmvivo | m_viewinfo.setTitle(this.title);
|
148 | 3608 | ldiaz | m_viewinfo.setHeight(500);
|
149 | m_viewinfo.setWidth(520);
|
||
150 | 312 | fernando | return m_viewinfo;
|
151 | } |
||
152 | |||
153 | 437 | fernando | /**
|
154 | 6122 | jaume | * This method initializes jPanel
|
155 | *
|
||
156 | * @return javax.swing.JPanel
|
||
157 | */
|
||
158 | private AcceptCancelPanel getJPanel() {
|
||
159 | 437 | fernando | if (jPanel == null) { |
160 | 6122 | jaume | ActionListener okAction = new java.awt.event.ActionListener() { |
161 | 437 | fernando | public void actionPerformed(java.awt.event.ActionEvent e) { |
162 | accepted = true;
|
||
163 | 600 | fjp | if (PluginServices.getMainFrame() == null) { |
164 | 437 | fernando | ((JDialog) (getParent().getParent().getParent()
|
165 | .getParent())).dispose(); |
||
166 | } else {
|
||
167 | 6880 | cesar | PluginServices.getMDIManager().closeWindow((IWindow) FOpenDialog.this); |
168 | 437 | fernando | } |
169 | } |
||
170 | 6122 | jaume | }; |
171 | ActionListener cancelAction = new java.awt.event.ActionListener() { |
||
172 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
173 | 1115 | fjp | if (PluginServices.getMainFrame() != null) { |
174 | 6880 | cesar | PluginServices.getMDIManager().closeWindow((IWindow) FOpenDialog.this); |
175 | 437 | fernando | } else {
|
176 | ((JDialog) (getParent().getParent().getParent()
|
||
177 | .getParent())).dispose(); |
||
178 | } |
||
179 | } |
||
180 | 6122 | jaume | }; |
181 | jPanel = new AcceptCancelPanel(okAction, cancelAction);
|
||
182 | 437 | fernando | } |
183 | 6122 | jaume | return jPanel;
|
184 | 437 | fernando | } |
185 | 6122 | jaume | |
186 | |||
187 | 437 | fernando | public boolean isAccepted() { |
188 | return accepted;
|
||
189 | } |
||
190 | 6122 | jaume | |
191 | 858 | fernando | 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 | 6122 | jaume | getJPanel().setOkButtonEnabled(finishable); |
204 | 858 | fernando | } |
205 | 6122 | jaume | |
206 | 858 | fernando | } |
207 | 904 | fjp | public static IProjection getLastProjection() { |
208 | 7287 | jaume | // no entiendo porqu? se necesita esto aqu?...
|
209 | if (proj == null) |
||
210 | proj = Project.getDefaultProjection(); |
||
211 | 904 | fjp | return proj;
|
212 | } |
||
213 | 7287 | jaume | |
214 | 904 | fjp | public static void setLastProjection(IProjection proj) { |
215 | FOpenDialog.proj = proj; |
||
216 | } |
||
217 | 437 | fernando | } // @jve:decl-index=0:visual-constraint="10,10"
|
218 | 312 | fernando | // @jve:visual-info decl-index=0 visual-constraint="10,10"
|
219 | // @jve:visual-info decl-index=0 visual-constraint="10,10" |