Statistics
| Revision:

root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / core / gui / GeoprocessPaneContainer.java @ 8235

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