svn-gvsig-desktop / tags / v1_0_2_Build_912 / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / core / gui / GeoprocessPaneContainer.java @ 11422
History | View | Annotate | Download (6.19 KB)
1 | 5412 | azabala | /*
|
---|---|---|---|
2 | * Created on 28-mar-2006
|
||
3 | *
|
||
4 | * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | *
|
||
6 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or
|
||
9 | * modify it under the terms of the GNU General Public License
|
||
10 | * as published by the Free Software Foundation; either version 2
|
||
11 | * of the License, or (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful,
|
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | * GNU General Public License for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License
|
||
19 | * along with this program; if not, write to the Free Software
|
||
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
21 | *
|
||
22 | * For more information, contact:
|
||
23 | *
|
||
24 | * Generalitat Valenciana
|
||
25 | * Conselleria d'Infraestructures i Transport
|
||
26 | * Av. Blasco Ib??ez, 50
|
||
27 | * 46010 VALENCIA
|
||
28 | * SPAIN
|
||
29 | *
|
||
30 | * +34 963862235
|
||
31 | * gvsig@gva.es
|
||
32 | * www.gvsig.gva.es
|
||
33 | *
|
||
34 | * or
|
||
35 | *
|
||
36 | * IVER T.I. S.A
|
||
37 | * Salamanca 50
|
||
38 | * 46005 Valencia
|
||
39 | * Spain
|
||
40 | *
|
||
41 | * +34 963163400
|
||
42 | * dac@iver.es
|
||
43 | */
|
||
44 | /* CVS MESSAGES:
|
||
45 | *
|
||
46 | * $Id$
|
||
47 | * $Log$
|
||
48 | 8770 | caballero | * Revision 1.6.2.4 2006-11-15 08:29:55 caballero
|
49 | * cerrar la IWindow de andami, para poder guardar el proyecto
|
||
50 | *
|
||
51 | * Revision 1.6.2.3 2006/11/15 00:08:17 jjdelcerro
|
||
52 | 8765 | jjdelcerro | * *** empty log message ***
|
53 | 7332 | caballero | *
|
54 | 8765 | jjdelcerro | * Revision 1.8 2006/10/23 10:27:23 caballero
|
55 | * ancho y alto del panel
|
||
56 | 7306 | azabala | *
|
57 | 8765 | jjdelcerro | * Revision 1.7 2006/09/18 11:02:20 caballero
|
58 | * cambio tama?o container
|
||
59 | *
|
||
60 | 7306 | azabala | * Revision 1.6 2006/08/29 07:56:30 cesar
|
61 | 6880 | cesar | * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
|
62 | *
|
||
63 | * Revision 1.5 2006/08/29 07:13:56 cesar
|
||
64 | 6877 | cesar | * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
|
65 | *
|
||
66 | * Revision 1.4 2006/08/11 16:12:27 azabala
|
||
67 | 6179 | azabala | * *** empty log message ***
|
68 | *
|
||
69 | 6745 | azabala | * Revision 1.3 2006/07/04 16:42:37 azabala
|
70 | * *** empty log message ***
|
||
71 | *
|
||
72 | 6179 | azabala | * Revision 1.2 2006/05/25 08:20:43 jmvivo
|
73 | 5424 | jmvivo | * Modificado para que, si el proceso no ha podido ejecutarse, no cierre la ventana
|
74 | *
|
||
75 | * Revision 1.1 2006/05/24 21:13:09 azabala
|
||
76 | 5412 | azabala | * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
|
77 | *
|
||
78 | * Revision 1.1 2006/04/11 17:55:51 azabala
|
||
79 | * primera version en cvs
|
||
80 | *
|
||
81 | * Revision 1.2 2006/04/07 19:00:58 azabala
|
||
82 | * *** empty log message ***
|
||
83 | *
|
||
84 | * Revision 1.1 2006/03/28 16:26:45 azabala
|
||
85 | * *** empty log message ***
|
||
86 | *
|
||
87 | *
|
||
88 | */
|
||
89 | package com.iver.cit.gvsig.geoprocess.core.gui; |
||
90 | |||
91 | 6745 | azabala | import java.awt.BorderLayout; |
92 | import java.awt.Component; |
||
93 | import java.awt.Container; |
||
94 | import java.awt.Window; |
||
95 | import java.awt.event.ActionEvent; |
||
96 | import java.awt.event.ActionListener; |
||
97 | |||
98 | 5412 | azabala | import javax.swing.JPanel; |
99 | |||
100 | 6745 | azabala | import org.gvsig.gui.beans.AcceptCancelPanel; |
101 | |||
102 | 5412 | azabala | import com.iver.andami.PluginServices; |
103 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
104 | 6880 | cesar | import com.iver.andami.ui.mdiManager.WindowInfo; |
105 | 5412 | azabala | import com.iver.cit.gvsig.geoprocess.core.IGeoprocessController; |
106 | /**
|
||
107 | * This GUI class is a container to show gui components associated to
|
||
108 | * a geoprocess.
|
||
109 | * To correctly execute the geoprocess associated, this PaneContainer must
|
||
110 | 8765 | jjdelcerro | * receive an AndamiCommand instance, which is controller class that
|
111 | 5412 | azabala | * knows how to invoque geoprocess
|
112 | * @author azabala
|
||
113 | *
|
||
114 | */
|
||
115 | 6877 | cesar | public class GeoprocessPaneContainer extends JPanel implements IWindow { |
116 | 5412 | azabala | private static final long serialVersionUID = 1L; |
117 | 6745 | azabala | private AcceptCancelPanel buttonPanel = null; |
118 | private JPanel mainPanel = new JPanel(); // @jve:decl-index=0:visual-constraint="10,10" |
||
119 | 6880 | cesar | private WindowInfo viewInfo = null; |
120 | 5412 | azabala | private IGeoprocessController controller;
|
121 | |||
122 | 6745 | azabala | private ActionListener okActionListener = new ActionListener(){ |
123 | public void actionPerformed(ActionEvent arg0) { |
||
124 | if (controller.launchGeoprocess()) {
|
||
125 | //So controller will launch geoprocess in background,
|
||
126 | //we can call cancel to close dialog
|
||
127 | cancel(); |
||
128 | } |
||
129 | } |
||
130 | }; |
||
131 | 8765 | jjdelcerro | |
132 | 6745 | azabala | private ActionListener cancelActionListener = new ActionListener(){ |
133 | public void actionPerformed(ActionEvent arg0) { |
||
134 | cancel(); |
||
135 | } |
||
136 | }; |
||
137 | 8765 | jjdelcerro | |
138 | 5412 | azabala | /**
|
139 | * Constructor from GUI component associated to a geoprocess
|
||
140 | * @param mainPanel
|
||
141 | */
|
||
142 | public GeoprocessPaneContainer(JPanel mainPanel) { |
||
143 | super();
|
||
144 | this.mainPanel = mainPanel;
|
||
145 | initialize(); |
||
146 | } |
||
147 | /**
|
||
148 | * Implementation of ViewInfo andami interface.
|
||
149 | */
|
||
150 | 6880 | cesar | public WindowInfo getWindowInfo() {
|
151 | 5412 | azabala | if (viewInfo == null) { |
152 | 6880 | cesar | viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
153 | 5412 | azabala | viewInfo.setTitle(PluginServices.getText(this,
|
154 | "Herramientas_de_analisis"));
|
||
155 | 8765 | jjdelcerro | viewInfo.setWidth(controller.getWidth()); |
156 | viewInfo.setHeight(controller.getHeight()); |
||
157 | 5412 | azabala | } |
158 | return viewInfo;
|
||
159 | } |
||
160 | 8765 | jjdelcerro | |
161 | 5412 | azabala | /**
|
162 | * Sets AndamiCmd instance, which knows how to run geoprocess
|
||
163 | * from user inputs in main panel.
|
||
164 | * @param command
|
||
165 | */
|
||
166 | public void setCommand(IGeoprocessController controller){ |
||
167 | this.controller = controller;
|
||
168 | } |
||
169 | |||
170 | /**
|
||
171 | * This method initializes this
|
||
172 | 8765 | jjdelcerro | *
|
173 | 5412 | azabala | * @return void
|
174 | */
|
||
175 | private void initialize() { |
||
176 | 6745 | azabala | // this.setLayout(new BorderLayout(10, 10));
|
177 | 5412 | azabala | this.setLayout(new BorderLayout()); |
178 | 6745 | azabala | // mainPanel.setSize(new java.awt.Dimension(430,390));
|
179 | this.setSize(new java.awt.Dimension(570,460)); |
||
180 | this.add(getMainPanel(), java.awt.BorderLayout.NORTH);
|
||
181 | 5412 | azabala | this.add(getButtonPanel(), java.awt.BorderLayout.SOUTH);
|
182 | 8765 | jjdelcerro | |
183 | 5412 | azabala | this.validate();
|
184 | } |
||
185 | |||
186 | 6745 | azabala | private JPanel getMainPanel() { |
187 | return mainPanel;
|
||
188 | } |
||
189 | 5412 | azabala | /**
|
190 | 8765 | jjdelcerro | * This method initializes buttonPanel
|
191 | *
|
||
192 | * @return javax.swing.JPanel
|
||
193 | 5412 | azabala | */
|
194 | 6745 | azabala | private AcceptCancelPanel getButtonPanel() {
|
195 | 5412 | azabala | if (buttonPanel == null) { |
196 | 6745 | azabala | buttonPanel = new AcceptCancelPanel();
|
197 | buttonPanel.setOkButtonActionListener(okActionListener); |
||
198 | buttonPanel.setCancelButtonActionListener(cancelActionListener); |
||
199 | 5412 | azabala | } |
200 | return buttonPanel;
|
||
201 | } |
||
202 | |||
203 | /**
|
||
204 | * Closes parent dialog
|
||
205 | *
|
||
206 | */
|
||
207 | public void cancel(){ |
||
208 | 8770 | caballero | if (PluginServices.getMainFrame() == null) { |
209 | Container container = getParent();
|
||
210 | Container parentOfContainer = null; |
||
211 | while(! (container instanceof Window)){ |
||
212 | parentOfContainer = container.getParent(); |
||
213 | container = parentOfContainer; |
||
214 | } |
||
215 | ((Window)container).dispose();
|
||
216 | }else {
|
||
217 | PluginServices.getMDIManager().closeWindow(GeoprocessPaneContainer.this); |
||
218 | 5412 | azabala | } |
219 | } |
||
220 | |||
221 | } // @jve:decl-index=0:visual-constraint="31,13" |