Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / core / gui / GeoprocessPaneContainer.java @ 8745

History | View | Annotate | Download (5.99 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 8745 2006-11-14 13:14:23Z  $
47
 * $Log$
48
 * Revision 1.6.2.2  2006-09-19 06:46:48  caballero
49
 * cambio size
50
 *
51
 * Revision 1.6.2.1  2006/09/15 15:07:08  azabala
52
 * adjusted panel with to try to solve visualization problems in certain O.S and monitors
53
 *
54
 * Revision 1.6  2006/08/29 07:56:30  cesar
55
 * 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
 * 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
 * *** empty log message ***
62
 *
63
 * Revision 1.3  2006/07/04 16:42:37  azabala
64
 * *** empty log message ***
65
 *
66
 * Revision 1.2  2006/05/25 08:20:43  jmvivo
67
 * 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
 * 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
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
import javax.swing.JPanel;
93

    
94
import org.gvsig.gui.beans.AcceptCancelPanel;
95

    
96
import com.iver.andami.PluginServices;
97
import com.iver.andami.ui.mdiManager.IWindow;
98
import com.iver.andami.ui.mdiManager.WindowInfo;
99
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
 * receive an AndamiCommand instance, which is controller class that 
105
 * knows how to invoque geoprocess
106
 * @author azabala
107
 *
108
 */
109
public class GeoprocessPaneContainer extends JPanel implements IWindow {
110
        private static final long serialVersionUID = 1L;
111
        private AcceptCancelPanel buttonPanel = null;
112
        private JPanel mainPanel = new JPanel();  //  @jve:decl-index=0:visual-constraint="10,10"
113
        private WindowInfo viewInfo = null;
114
        private IGeoprocessController controller;
115

    
116
        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
        
126
        private ActionListener cancelActionListener = new ActionListener(){
127
                public void actionPerformed(ActionEvent arg0) {
128
                        cancel();
129
                }
130
        };
131
        
132
        /**
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
        public WindowInfo getWindowInfo() {
145
                if (viewInfo == null) {
146
                        viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
147
                        viewInfo.setTitle(PluginServices.getText(this,
148
                                        "Herramientas_de_analisis"));
149
                        viewInfo.setWidth(750);
150
                        viewInfo.setHeight(500);
151
                }
152
                
153
//                viewInfo.setWidth(mainPanel.getWidth() + 40);
154
//                viewInfo.setHeight(mainPanel.getHeight() + 40);
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
                Container container = getParent();
206
                Container parentOfContainer = null;
207
                while(! (container instanceof Window)){
208
                        parentOfContainer = container.getParent();
209
                        container = parentOfContainer;
210
                }
211
                ((Window)container).dispose();        
212
        }
213

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