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