root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / core / gui / GeoprocessPaneContainer.java @ 6179
History | View | Annotate | Download (5.86 KB)
1 |
/*
|
---|---|
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: GeoprocessPaneContainer.java 6179 2006-07-04 16:43:18Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.3 2006-07-04 16:42:37 azabala
|
49 |
* *** empty log message ***
|
50 |
*
|
51 |
* Revision 1.2 2006/05/25 08:20:43 jmvivo
|
52 |
* Modificado para que, si el proceso no ha podido ejecutarse, no cierre la ventana
|
53 |
*
|
54 |
* Revision 1.1 2006/05/24 21:13:09 azabala
|
55 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
|
56 |
*
|
57 |
* Revision 1.1 2006/04/11 17:55:51 azabala
|
58 |
* primera version en cvs
|
59 |
*
|
60 |
* Revision 1.2 2006/04/07 19:00:58 azabala
|
61 |
* *** empty log message ***
|
62 |
*
|
63 |
* Revision 1.1 2006/03/28 16:26:45 azabala
|
64 |
* *** empty log message ***
|
65 |
*
|
66 |
*
|
67 |
*/
|
68 |
package com.iver.cit.gvsig.geoprocess.core.gui; |
69 |
|
70 |
import javax.swing.JPanel; |
71 |
|
72 |
import com.iver.andami.PluginServices; |
73 |
import com.iver.andami.ui.mdiManager.View; |
74 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
75 |
import com.iver.cit.gvsig.geoprocess.core.IGeoprocessController; |
76 |
|
77 |
import javax.swing.JButton; |
78 |
import java.awt.BorderLayout; |
79 |
import java.awt.Container; |
80 |
import java.awt.Window; |
81 |
/**
|
82 |
* This GUI class is a container to show gui components associated to
|
83 |
* a geoprocess.
|
84 |
* To correctly execute the geoprocess associated, this PaneContainer must
|
85 |
* receive an AndamiCommand instance, which is controller class that
|
86 |
* knows how to invoque geoprocess
|
87 |
* @author azabala
|
88 |
*
|
89 |
*/
|
90 |
public class GeoprocessPaneContainer extends JPanel implements View { |
91 |
private static final long serialVersionUID = 1L; |
92 |
private JPanel buttonPanel = null; |
93 |
private JPanel mainPanel = null; |
94 |
private JButton okButton = null; |
95 |
private JButton cancelButton = null; |
96 |
|
97 |
private ViewInfo viewInfo = null; |
98 |
private IGeoprocessController controller;
|
99 |
|
100 |
|
101 |
|
102 |
/**
|
103 |
* Constructor from GUI component associated to a geoprocess
|
104 |
* @param mainPanel
|
105 |
*/
|
106 |
public GeoprocessPaneContainer(JPanel mainPanel) { |
107 |
super();
|
108 |
this.mainPanel = mainPanel;
|
109 |
initialize(); |
110 |
} |
111 |
/**
|
112 |
* Implementation of ViewInfo andami interface.
|
113 |
*/
|
114 |
public ViewInfo getViewInfo() {
|
115 |
if (viewInfo == null) { |
116 |
viewInfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
117 |
viewInfo.setTitle(PluginServices.getText(this,
|
118 |
"Herramientas_de_analisis"));
|
119 |
viewInfo.setWidth(450);
|
120 |
viewInfo.setHeight(350);
|
121 |
} |
122 |
return viewInfo;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* Sets the main panel (GUI component associated to a geoprocess)
|
127 |
* @param geoprocessPanel
|
128 |
*/
|
129 |
public void setMainPanel(JPanel geoprocessPanel){ |
130 |
this.add(geoprocessPanel, BorderLayout.NORTH); |
131 |
this.validate();
|
132 |
} |
133 |
/**
|
134 |
* Sets AndamiCmd instance, which knows how to run geoprocess
|
135 |
* from user inputs in main panel.
|
136 |
* @param command
|
137 |
*/
|
138 |
public void setCommand(IGeoprocessController controller){ |
139 |
this.controller = controller;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* This method initializes this
|
144 |
*
|
145 |
* @return void
|
146 |
*/
|
147 |
private void initialize() { |
148 |
this.setLayout(new BorderLayout()); |
149 |
this.add(getButtonPanel(), java.awt.BorderLayout.SOUTH);
|
150 |
this.add(getMainPanel(), java.awt.BorderLayout.CENTER);
|
151 |
this.validate();
|
152 |
} |
153 |
|
154 |
/**
|
155 |
* This method initializes buttonPanel
|
156 |
*
|
157 |
* @return javax.swing.JPanel
|
158 |
*/
|
159 |
private JPanel getButtonPanel() { |
160 |
if (buttonPanel == null) { |
161 |
buttonPanel = new JPanel(); |
162 |
buttonPanel.add(getCancelButton(), null);
|
163 |
buttonPanel.add(getOkButton(), null);
|
164 |
} |
165 |
return buttonPanel;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* This method initializes mainPanel
|
170 |
*
|
171 |
* @return javax.swing.JPanel
|
172 |
*/
|
173 |
private JPanel getMainPanel() { |
174 |
return mainPanel;
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* This method initializes okButton
|
179 |
*
|
180 |
* @return javax.swing.JButton
|
181 |
*/
|
182 |
private JButton getOkButton() { |
183 |
if (okButton == null) { |
184 |
okButton = new JButton(); |
185 |
okButton.setText(PluginServices.getText(this, "Terminar")); |
186 |
okButton.addActionListener(new java.awt.event.ActionListener() {
|
187 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
188 |
if (controller.launchGeoprocess()) {
|
189 |
//So controller will launch geoprocess in background,
|
190 |
//we can call cancel to close dialog
|
191 |
cancel(); |
192 |
} |
193 |
} |
194 |
}); |
195 |
} |
196 |
return okButton;
|
197 |
} |
198 |
|
199 |
/**
|
200 |
* This method initializes cancelButton
|
201 |
*
|
202 |
* @return javax.swing.JButton
|
203 |
*/
|
204 |
private JButton getCancelButton() { |
205 |
if (cancelButton == null) { |
206 |
cancelButton = new JButton(); |
207 |
cancelButton.setText(PluginServices.getText(this, "Cerrar")); |
208 |
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
209 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
210 |
cancel(); |
211 |
} |
212 |
}); |
213 |
} |
214 |
return cancelButton;
|
215 |
} |
216 |
/**
|
217 |
* Closes parent dialog
|
218 |
*
|
219 |
*/
|
220 |
public void cancel(){ |
221 |
Container container = getParent();
|
222 |
Container parentOfContainer = null; |
223 |
while(! (container instanceof Window)){ |
224 |
parentOfContainer = container.getParent(); |
225 |
container = parentOfContainer; |
226 |
} |
227 |
((Window)container).dispose();
|
228 |
} |
229 |
|
230 |
} // @jve:decl-index=0:visual-constraint="31,13"
|