Statistics
| Revision:

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

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

    
82
import java.awt.BorderLayout;
83
import java.awt.Component;
84
import java.awt.Container;
85
import java.awt.Window;
86
import java.awt.event.ActionEvent;
87
import java.awt.event.ActionListener;
88

    
89
import javax.swing.JPanel;
90

    
91
import org.gvsig.gui.beans.AcceptCancelPanel;
92

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

    
113
        private ActionListener okActionListener = new ActionListener(){
114
                public void actionPerformed(ActionEvent arg0) {
115
                        if (controller.launchGeoprocess()) {
116
                                //So controller will launch geoprocess in background,
117
                                //we can call cancel to close dialog
118
                                cancel();
119
                        }
120
                }
121
        };
122

    
123
        private ActionListener cancelActionListener = new ActionListener(){
124
                public void actionPerformed(ActionEvent arg0) {
125
                        cancel();
126
                }
127
        };
128

    
129
        /**
130
         * Constructor from GUI component associated to a geoprocess
131
         * @param mainPanel
132
         */
133
        public GeoprocessPaneContainer(JPanel mainPanel) {
134
                super();
135
                this.mainPanel = mainPanel;
136
                initialize();
137
        }
138
        /**
139
         * Implementation of ViewInfo andami interface.
140
         */
141
        public WindowInfo getWindowInfo() {
142
                if (viewInfo == null) {
143
                        viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
144
                        viewInfo.setTitle(PluginServices.getText(this,
145
                                        "Herramientas_de_analisis"));
146
                        viewInfo.setWidth(750);
147
                        viewInfo.setHeight(500);
148
                }
149
                return viewInfo;
150
        }
151

    
152
        /**
153
         * Sets AndamiCmd instance, which knows how to run geoprocess
154
         * from user inputs in main panel.
155
         * @param command
156
         */
157
        public void setCommand(IGeoprocessController controller){
158
                this.controller = controller;
159
        }
160

    
161
        /**
162
         * This method initializes this
163
         *
164
         * @return void
165
         */
166
        private void initialize() {
167
//                this.setLayout(new BorderLayout(10, 10));
168
                this.setLayout(new BorderLayout());
169
//                mainPanel.setSize(new java.awt.Dimension(430,390));
170
                this.setSize(new java.awt.Dimension(570,460));
171
                this.add(getMainPanel(), java.awt.BorderLayout.NORTH);
172
                this.add(getButtonPanel(), java.awt.BorderLayout.SOUTH);
173

    
174
                this.validate();
175
        }
176

    
177
        private JPanel getMainPanel() {
178
                return mainPanel;
179
        }
180
        /**
181
         * This method initializes buttonPanel
182
         *
183
         * @return javax.swing.JPanel
184
         */
185
        private AcceptCancelPanel getButtonPanel() {
186
                if (buttonPanel == null) {
187
                        buttonPanel = new AcceptCancelPanel();
188
                        buttonPanel.setOkButtonActionListener(okActionListener);
189
                        buttonPanel.setCancelButtonActionListener(cancelActionListener);
190
                }
191
                return buttonPanel;
192
        }
193

    
194
        /**
195
         * Closes parent dialog
196
         *
197
         */
198
        public void cancel(){
199
                Container container = getParent();
200
                Container parentOfContainer = null;
201
                while(! (container instanceof Window)){
202
                        parentOfContainer = container.getParent();
203
                        container = parentOfContainer;
204
                }
205
                ((Window)container).dispose();
206
        }
207

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