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 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 7322 caballero
 * 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 6880 cesar
 * 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 6877 cesar
 * 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 6179 azabala
 * *** empty log message ***
59
 *
60 6745 azabala
 * Revision 1.3  2006/07/04 16:42:37  azabala
61
 * *** empty log message ***
62
 *
63 6179 azabala
 * Revision 1.2  2006/05/25 08:20:43  jmvivo
64 5424 jmvivo
 * 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 5412 azabala
 * 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 6745 azabala
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 5412 azabala
import javax.swing.JPanel;
90
91 6745 azabala
import org.gvsig.gui.beans.AcceptCancelPanel;
92
93 5412 azabala
import com.iver.andami.PluginServices;
94 6877 cesar
import com.iver.andami.ui.mdiManager.IWindow;
95 6880 cesar
import com.iver.andami.ui.mdiManager.WindowInfo;
96 5412 azabala
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 7322 caballero
 * receive an AndamiCommand instance, which is controller class that
102 5412 azabala
 * knows how to invoque geoprocess
103
 * @author azabala
104
 *
105
 */
106 6877 cesar
public class GeoprocessPaneContainer extends JPanel implements IWindow {
107 5412 azabala
        private static final long serialVersionUID = 1L;
108 6745 azabala
        private AcceptCancelPanel buttonPanel = null;
109
        private JPanel mainPanel = new JPanel();  //  @jve:decl-index=0:visual-constraint="10,10"
110 6880 cesar
        private WindowInfo viewInfo = null;
111 5412 azabala
        private IGeoprocessController controller;
112
113 6745 azabala
        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 7322 caballero
123 6745 azabala
        private ActionListener cancelActionListener = new ActionListener(){
124
                public void actionPerformed(ActionEvent arg0) {
125
                        cancel();
126
                }
127
        };
128 7322 caballero
129 5412 azabala
        /**
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 6880 cesar
        public WindowInfo getWindowInfo() {
142 5412 azabala
                if (viewInfo == null) {
143 6880 cesar
                        viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
144 5412 azabala
                        viewInfo.setTitle(PluginServices.getText(this,
145
                                        "Herramientas_de_analisis"));
146 7322 caballero
                        viewInfo.setWidth(750);
147
                        viewInfo.setHeight(500);
148 5412 azabala
                }
149
                return viewInfo;
150
        }
151 7322 caballero
152 5412 azabala
        /**
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 7322 caballero
         *
164 5412 azabala
         * @return void
165
         */
166
        private void initialize() {
167 6745 azabala
//                this.setLayout(new BorderLayout(10, 10));
168 5412 azabala
                this.setLayout(new BorderLayout());
169 6745 azabala
//                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 5412 azabala
                this.add(getButtonPanel(), java.awt.BorderLayout.SOUTH);
173 7322 caballero
174 5412 azabala
                this.validate();
175
        }
176
177 6745 azabala
        private JPanel getMainPanel() {
178
                return mainPanel;
179
        }
180 5412 azabala
        /**
181 7322 caballero
         * This method initializes buttonPanel
182
         *
183
         * @return javax.swing.JPanel
184 5412 azabala
         */
185 6745 azabala
        private AcceptCancelPanel getButtonPanel() {
186 5412 azabala
                if (buttonPanel == null) {
187 6745 azabala
                        buttonPanel = new AcceptCancelPanel();
188
                        buttonPanel.setOkButtonActionListener(okActionListener);
189
                        buttonPanel.setCancelButtonActionListener(cancelActionListener);
190 5412 azabala
                }
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 7322 caballero
                ((Window)container).dispose();
206 5412 azabala
        }
207
208
}  //  @jve:decl-index=0:visual-constraint="31,13"