Statistics
| Revision:

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

History | View | Annotate | Download (6.1 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 8769 2006-11-15 08:01:54Z caballero $
47
 * $Log$
48
 * Revision 1.9  2006-11-15 08:01:54  caballero
49
 * soluci?n al guardar la interfaz gr?fica en el proyecto
50
 *
51
 * Revision 1.8  2006/10/23 10:27:23  caballero
52
 * ancho y alto del panel
53
 *
54
 * Revision 1.7  2006/09/18 11:02:20  caballero
55
 * cambio tama?o container
56
 *
57
 * Revision 1.6  2006/08/29 07:56:30  cesar
58
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
59
 *
60
 * Revision 1.5  2006/08/29 07:13:56  cesar
61
 * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
62
 *
63
 * Revision 1.4  2006/08/11 16:12:27  azabala
64
 * *** empty log message ***
65
 *
66
 * Revision 1.3  2006/07/04 16:42:37  azabala
67
 * *** empty log message ***
68
 *
69
 * Revision 1.2  2006/05/25 08:20:43  jmvivo
70
 * Modificado para que, si el proceso no ha podido ejecutarse, no cierre la ventana
71
 *
72
 * Revision 1.1  2006/05/24 21:13:09  azabala
73
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
74
 *
75
 * Revision 1.1  2006/04/11 17:55:51  azabala
76
 * primera version en cvs
77
 *
78
 * Revision 1.2  2006/04/07 19:00:58  azabala
79
 * *** empty log message ***
80
 *
81
 * Revision 1.1  2006/03/28 16:26:45  azabala
82
 * *** empty log message ***
83
 *
84
 *
85
 */
86
package com.iver.cit.gvsig.geoprocess.core.gui;
87

    
88
import java.awt.BorderLayout;
89
import java.awt.Component;
90
import java.awt.Container;
91
import java.awt.Window;
92
import java.awt.event.ActionEvent;
93
import java.awt.event.ActionListener;
94

    
95
import javax.swing.JPanel;
96

    
97
import org.gvsig.gui.beans.AcceptCancelPanel;
98

    
99
import com.iver.andami.PluginServices;
100
import com.iver.andami.ui.mdiManager.IWindow;
101
import com.iver.andami.ui.mdiManager.WindowInfo;
102
import com.iver.cit.gvsig.geoprocess.core.IGeoprocessController;
103
/**
104
 * This GUI class is a container to show gui components associated to
105
 * a geoprocess.
106
 * To correctly execute the geoprocess associated, this PaneContainer must
107
 * receive an AndamiCommand instance, which is controller class that
108
 * knows how to invoque geoprocess
109
 * @author azabala
110
 *
111
 */
112
public class GeoprocessPaneContainer extends JPanel implements IWindow {
113
        private static final long serialVersionUID = 1L;
114
        private AcceptCancelPanel buttonPanel = null;
115
        private JPanel mainPanel = new JPanel();  //  @jve:decl-index=0:visual-constraint="10,10"
116
        private WindowInfo viewInfo = null;
117
        private IGeoprocessController controller;
118

    
119
        private ActionListener okActionListener = new ActionListener(){
120
                public void actionPerformed(ActionEvent arg0) {
121
                        if (controller.launchGeoprocess()) {
122
                                //So controller will launch geoprocess in background,
123
                                //we can call cancel to close dialog
124
                                cancel();
125
                        }
126
                }
127
        };
128

    
129
        private ActionListener cancelActionListener = new ActionListener(){
130
                public void actionPerformed(ActionEvent arg0) {
131
                        cancel();
132
                }
133
        };
134

    
135
        /**
136
         * Constructor from GUI component associated to a geoprocess
137
         * @param mainPanel
138
         */
139
        public GeoprocessPaneContainer(JPanel mainPanel) {
140
                super();
141
                this.mainPanel = mainPanel;
142
                initialize();
143
        }
144
        /**
145
         * Implementation of ViewInfo andami interface.
146
         */
147
        public WindowInfo getWindowInfo() {
148
                if (viewInfo == null) {
149
                        viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
150
                        viewInfo.setTitle(PluginServices.getText(this,
151
                                        "Herramientas_de_analisis"));
152
                        viewInfo.setWidth(controller.getWidth());
153
                        viewInfo.setHeight(controller.getHeight());
154
                }
155
                return viewInfo;
156
        }
157

    
158
        /**
159
         * Sets AndamiCmd instance, which knows how to run geoprocess
160
         * from user inputs in main panel.
161
         * @param command
162
         */
163
        public void setCommand(IGeoprocessController controller){
164
                this.controller = controller;
165
        }
166

    
167
        /**
168
         * This method initializes this
169
         *
170
         * @return void
171
         */
172
        private void initialize() {
173
//                this.setLayout(new BorderLayout(10, 10));
174
                this.setLayout(new BorderLayout());
175
//                mainPanel.setSize(new java.awt.Dimension(430,390));
176
                this.setSize(new java.awt.Dimension(570,460));
177
                this.add(getMainPanel(), java.awt.BorderLayout.NORTH);
178
                this.add(getButtonPanel(), java.awt.BorderLayout.SOUTH);
179

    
180
                this.validate();
181
        }
182

    
183
        private JPanel getMainPanel() {
184
                return mainPanel;
185
        }
186
        /**
187
         * This method initializes buttonPanel
188
         *
189
         * @return javax.swing.JPanel
190
         */
191
        private AcceptCancelPanel getButtonPanel() {
192
                if (buttonPanel == null) {
193
                        buttonPanel = new AcceptCancelPanel();
194
                        buttonPanel.setOkButtonActionListener(okActionListener);
195
                        buttonPanel.setCancelButtonActionListener(cancelActionListener);
196
                }
197
                return buttonPanel;
198
        }
199

    
200
        /**
201
         * Closes parent dialog
202
         *
203
         */
204
        public void cancel(){
205
                if (PluginServices.getMainFrame() == null) {
206
                        Container container = getParent();
207
                        Container parentOfContainer = null;
208
                        while(! (container instanceof Window)){
209
                                parentOfContainer = container.getParent();
210
                                container = parentOfContainer;
211
                        }
212
                        ((Window)container).dispose();
213
                }else {
214
                        PluginServices.getMDIManager().closeWindow(GeoprocessPaneContainer.this);
215
                }
216
        }
217

    
218
}  //  @jve:decl-index=0:visual-constraint="31,13"