svn-gvsig-desktop / trunk / extensions / extGeoProcessing / src / com / iver / gvsig / geoprocessing / GeoprocessPaneContainer.java @ 4820
History | View | Annotate | Download (5.42 KB)
1 | 4818 | 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 | * Revision 1.1 2006-04-11 17:55:51 azabala
|
||
49 | * primera version en cvs
|
||
50 | *
|
||
51 | * Revision 1.2 2006/04/07 19:00:58 azabala
|
||
52 | * *** empty log message ***
|
||
53 | *
|
||
54 | * Revision 1.1 2006/03/28 16:26:45 azabala
|
||
55 | * *** empty log message ***
|
||
56 | *
|
||
57 | *
|
||
58 | */
|
||
59 | package com.iver.gvsig.geoprocessing; |
||
60 | |||
61 | import javax.swing.JPanel; |
||
62 | |||
63 | import com.iver.andami.PluginServices; |
||
64 | import com.iver.andami.ui.mdiManager.View; |
||
65 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
66 | |||
67 | import javax.swing.JButton; |
||
68 | import java.awt.BorderLayout; |
||
69 | import java.awt.Container; |
||
70 | import java.awt.Window; |
||
71 | /**
|
||
72 | * This GUI class is a container to show gui components associated to
|
||
73 | * a geoprocess.
|
||
74 | * To correctly execute the geoprocess associated, this PaneContainer must
|
||
75 | * receive an AndamiCommand instance, which is controller class that
|
||
76 | * knows how to invoque geoprocess
|
||
77 | * @author azabala
|
||
78 | *
|
||
79 | */
|
||
80 | public class GeoprocessPaneContainer extends JPanel implements View { |
||
81 | private static final long serialVersionUID = 1L; |
||
82 | private JPanel buttonPanel = null; |
||
83 | private JPanel mainPanel = null; |
||
84 | private JButton okButton = null; |
||
85 | private JButton cancelButton = null; |
||
86 | |||
87 | private ViewInfo viewInfo = null; |
||
88 | private IGeoprocessController controller;
|
||
89 | |||
90 | |||
91 | |||
92 | /**
|
||
93 | * Constructor from GUI component associated to a geoprocess
|
||
94 | * @param mainPanel
|
||
95 | */
|
||
96 | public GeoprocessPaneContainer(JPanel mainPanel) { |
||
97 | super();
|
||
98 | this.mainPanel = mainPanel;
|
||
99 | initialize(); |
||
100 | } |
||
101 | /**
|
||
102 | * Implementation of ViewInfo andami interface.
|
||
103 | */
|
||
104 | public ViewInfo getViewInfo() {
|
||
105 | if (viewInfo == null) { |
||
106 | viewInfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
||
107 | viewInfo.setTitle(PluginServices.getText(this,
|
||
108 | "Herramientas_de_analisis"));
|
||
109 | } |
||
110 | return viewInfo;
|
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * Sets the main panel (GUI component associated to a geoprocess)
|
||
115 | * @param geoprocessPanel
|
||
116 | */
|
||
117 | public void setMainPanel(JPanel geoprocessPanel){ |
||
118 | this.add(geoprocessPanel, BorderLayout.NORTH); |
||
119 | this.validate();
|
||
120 | } |
||
121 | /**
|
||
122 | * Sets AndamiCmd instance, which knows how to run geoprocess
|
||
123 | * from user inputs in main panel.
|
||
124 | * @param command
|
||
125 | */
|
||
126 | public void setCommand(IGeoprocessController controller){ |
||
127 | this.controller = controller;
|
||
128 | } |
||
129 | |||
130 | /**
|
||
131 | * This method initializes this
|
||
132 | *
|
||
133 | * @return void
|
||
134 | */
|
||
135 | private void initialize() { |
||
136 | this.setLayout(new BorderLayout()); |
||
137 | this.setBounds(new java.awt.Rectangle(0,0,500,400)); |
||
138 | this.add(getButtonPanel(), java.awt.BorderLayout.SOUTH);
|
||
139 | this.add(getMainPanel(), java.awt.BorderLayout.CENTER);
|
||
140 | this.validate();
|
||
141 | } |
||
142 | |||
143 | /**
|
||
144 | * This method initializes buttonPanel
|
||
145 | *
|
||
146 | * @return javax.swing.JPanel
|
||
147 | */
|
||
148 | private JPanel getButtonPanel() { |
||
149 | if (buttonPanel == null) { |
||
150 | buttonPanel = new JPanel(); |
||
151 | buttonPanel.add(getCancelButton(), null);
|
||
152 | buttonPanel.add(getOkButton(), null);
|
||
153 | } |
||
154 | return buttonPanel;
|
||
155 | } |
||
156 | |||
157 | /**
|
||
158 | * This method initializes mainPanel
|
||
159 | *
|
||
160 | * @return javax.swing.JPanel
|
||
161 | */
|
||
162 | private JPanel getMainPanel() { |
||
163 | return mainPanel;
|
||
164 | } |
||
165 | |||
166 | /**
|
||
167 | * This method initializes okButton
|
||
168 | *
|
||
169 | * @return javax.swing.JButton
|
||
170 | */
|
||
171 | private JButton getOkButton() { |
||
172 | if (okButton == null) { |
||
173 | okButton = new JButton(); |
||
174 | okButton.setText(PluginServices.getText(this, "Terminar")); |
||
175 | okButton.addActionListener(new java.awt.event.ActionListener() {
|
||
176 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
177 | controller.launchGeoprocess(); |
||
178 | //So controller will launch geoprocess in background,
|
||
179 | //we can call cancel to close dialog
|
||
180 | cancel(); |
||
181 | } |
||
182 | }); |
||
183 | } |
||
184 | return okButton;
|
||
185 | } |
||
186 | |||
187 | /**
|
||
188 | * This method initializes cancelButton
|
||
189 | *
|
||
190 | * @return javax.swing.JButton
|
||
191 | */
|
||
192 | private JButton getCancelButton() { |
||
193 | if (cancelButton == null) { |
||
194 | cancelButton = new JButton(); |
||
195 | cancelButton.setText(PluginServices.getText(this, "Cerrar")); |
||
196 | cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
||
197 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
198 | cancel(); |
||
199 | } |
||
200 | }); |
||
201 | } |
||
202 | return cancelButton;
|
||
203 | } |
||
204 | /**
|
||
205 | * Closes parent dialog
|
||
206 | *
|
||
207 | */
|
||
208 | public void cancel(){ |
||
209 | Container container = getParent();
|
||
210 | Container parentOfContainer = null; |
||
211 | while(! (container instanceof Window)){ |
||
212 | parentOfContainer = container.getParent(); |
||
213 | container = parentOfContainer; |
||
214 | } |
||
215 | ((Window)container).dispose();
|
||
216 | } |
||
217 | |||
218 | } // @jve:decl-index=0:visual-constraint="31,13" |