Revision 8236 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/manager/GeoprocessManager.java

View differences:

GeoprocessManager.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.9  2006-09-21 18:17:48  azabala
48
 * Revision 1.10  2006-10-23 10:30:09  caballero
49
 * soluci?n refresco selecci?n por segunda vez un mismo control
50
 *
51
 * Revision 1.9  2006/09/21 18:17:48  azabala
49 52
 * fixed bug in JSplitPanel
50 53
 *
51 54
 * Revision 1.8  2006/08/29 07:56:30  cesar
......
83 86
import java.awt.event.MouseAdapter;
84 87
import java.awt.event.MouseEvent;
85 88
import java.io.IOException;
89
import java.net.URL;
86 90
import java.util.TreeMap;
87 91

  
88 92
import javax.swing.JButton;
......
111 115

  
112 116
/**
113 117
 * Main panel of the Geoprocess Manager gui component.
114
 * 
118
 *
115 119
 * It has a tree where shows all geoprocesses structure, and
116 120
 * buttons to open geoprocess' panel, and to close itself.
117
 * 
121
 *
118 122
 * It also listens for tree selection events.
119
 * 
123
 *
120 124
 * @author azabala
121 125
 *
122 126
 */
123
public class GeoprocessManager extends JPanel 
127
public class GeoprocessManager extends JPanel
124 128
	implements IWindow, TreeSelectionListener {
125
	
129

  
126 130
	/**
127 131
	 * Central panel wich has the geoprocess tree on left and
128 132
	 * the description panel on right
......
132 136
	 * Tree wich shows all registered geoprocesses
133 137
	 */
134 138
	private GeoprocessTree tree;
135
	
139

  
136 140
	/**
137 141
	 * It wraps htmlPane
138 142
	 */
139 143
	private JScrollPane scrollHtml;
140 144
	/**
141
	 * Panel wich shows description of selected packages or 
145
	 * Panel wich shows description of selected packages or
142 146
	 * geoprocesess
143 147
	 */
144
	private JEditorPane htmlPane;
148
	private MyJEditorPane htmlPane;
145 149
	/**
146 150
	 * It has the button "open geoprocess" and "close view"
147 151
	 */
148 152
	private JPanel jPanelButtons;
149
	
153

  
150 154
	/**
151 155
	 * Button to close the andami view
152 156
	 */
153 157
	private JButton jButtonClose;
154
	
158

  
155 159
	/**
156 160
	 * Button to open the selected geoprocess panel
157 161
	 */
158 162
	private JButton openGeoprocess;
159
	
160
	
163

  
164

  
161 165
	/**
162 166
	 * ViewInfo of andami
163 167
	 */
164 168
	private WindowInfo viewInfo;
165
	
169

  
166 170
	/**
167
	 * It has all package descriptions 
171
	 * It has all package descriptions
168 172
	 * (new plugins must register package descriptions
169 173
	 * here)
170 174
	 */
171 175
	private static TreeMap packageDescriptions =
172 176
		new TreeMap();
173
	
177

  
174 178
	public static void registerPackageDescription(String pkgName,
175 179
			String description){
176 180
		packageDescriptions.put(pkgName, description);
177 181
	}
178
	
182

  
179 183
	public static String getDescriptionFor(String pkgName){
180 184
		return (String) packageDescriptions.get(pkgName);
181 185
	}
182
	
186

  
183 187
	/**
184 188
	 * This is the default constructor
185 189
	 */
......
187 191
		super();
188 192
		initialize();
189 193
	}
190
	
191
	
194

  
195

  
192 196
	public WindowInfo getWindowInfo() {
193 197
		if (viewInfo == null) {
194
			viewInfo = new WindowInfo(WindowInfo.MODELESSDIALOG | 
195
										WindowInfo.RESIZABLE | 
198
			viewInfo = new WindowInfo(WindowInfo.MODELESSDIALOG |
199
										WindowInfo.RESIZABLE |
196 200
										WindowInfo.PALETTE);
197 201
			viewInfo.setTitle(PluginServices.
198 202
					getText(this, "Gestor_de_Geoprocesos"));
......
204 208

  
205 209
	/**
206 210
	 * This method initializes this
207
	 * 
211
	 *
208 212
	 * @return void
209 213
	 */
210 214
	private void initialize() {
......
218 222
		 * see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4182558
219 223
		 * JSplitPane doesnt care setDividerLocation calls before
220 224
		 * its container would be visible
221
		 * 
225
		 *
222 226
		 * */
223 227
		getJSplitPaneCenter().addComponentListener( new ComponentAdapter() {
224 228
			  public void componentResized( ComponentEvent event ) {
......
226 230
				  getJSplitPaneCenter().removeComponentListener( this );
227 231
			  }
228 232
			} );
229
		
233

  
230 234
	}
231 235

  
232 236
	private JSplitPane getJSplitPaneCenter() {
......
245 249
		}
246 250
		return tree;
247 251
	}
248
	
252

  
249 253
	class GeopTreeMouseListener extends MouseAdapter{
250 254

  
251 255
		public void mousePressed(MouseEvent e){
......
260 264
						getUserObject();
261 265
				if(!(o instanceof IGeoprocessPlugin))
262 266
					return;
263
				IGeoprocessPlugin geoprocess = 
267
				IGeoprocessPlugin geoprocess =
264 268
					(IGeoprocessPlugin) o;
265 269
				if(geoprocess == null){
266 270
					String error = PluginServices.
......
271 275
							errorDescription, error,
272 276
							JOptionPane.ERROR_MESSAGE);
273 277
				}
274
				IGeoprocessPanel panel = 
278
				IGeoprocessPanel panel =
275 279
					geoprocess.getGeoprocessPanel();
276
		        GeoprocessPaneContainer container = new 
280
		        GeoprocessPaneContainer container = new
277 281
					GeoprocessPaneContainer((JPanel)panel);
278 282
		        IGeoprocessController controller =
279 283
		        	geoprocess.getGpController();
......
286 290
		}
287 291
	}
288 292

  
289
	
293

  
290 294
	private JScrollPane getHtmlPane(){
291 295
		if(scrollHtml == null){
292 296
			scrollHtml = new JScrollPane();
293
			htmlPane = new JEditorPane();
297
			htmlPane = new MyJEditorPane();
294 298
	        htmlPane.setEditable(false);
295 299
	        htmlPane.setEditorKit(new HTMLEditorKit());
296 300
	        scrollHtml.setViewportView(htmlPane);
297
			
301

  
298 302
		}
299 303
		return scrollHtml;
300 304
	}
301
	
305

  
302 306
	private JPanel getJPanelButtons() {
303 307
		if (jPanelButtons == null) {
304 308
			jPanelButtons = new JPanel(new BorderLayout());
......
314 318
		}
315 319
		return jPanelButtons;
316 320
	}
317
	
321

  
318 322
	public void openGeoprocessPanel(){
319
		IGeoprocessPlugin geoprocess = 
323
		IGeoprocessPlugin geoprocess =
320 324
			tree.getGeoprocess();
321 325
		if(geoprocess == null){
322 326
			String error = PluginServices.
......
327 331
					JOptionPane.ERROR_MESSAGE);
328 332
			return;
329 333
		}
330
		IGeoprocessPanel panel = 
334
		IGeoprocessPanel panel =
331 335
			geoprocess.getGeoprocessPanel();
332
        GeoprocessPaneContainer container = new 
336
        GeoprocessPaneContainer container = new
333 337
			GeoprocessPaneContainer((JPanel)panel);
334 338
        IGeoprocessController controller =
335 339
        	geoprocess.getGpController();
......
339 343
        container.repaint();
340 344
        PluginServices.getMDIManager().addWindow(container);
341 345
	}
342
	
346

  
343 347
	private JButton getJButtonOpenGeop() {
344 348
		if (openGeoprocess == null) {
345 349
			openGeoprocess = new JButton();
......
355 359
		}
356 360
		return openGeoprocess;
357 361
	}
358
	
359
	
362

  
363

  
360 364
	private JButton getJButtonClose() {
361 365
		if (jButtonClose == null) {
362 366
			jButtonClose = new JButton();
......
366 370
						PluginServices.
367 371
						getMDIManager().
368 372
							closeWindow(GeoprocessManager.this);
369
					
373

  
370 374
				}
371 375
			});
372 376
		}
373 377
		return jButtonClose;
374 378
	}
375
	
376
	
377
	
379

  
380

  
381

  
378 382
	/**
379 383
	 * processes tree selection events.
380 384
	 */
......
384 388
								getLastPathComponent();
385 389
		Object userObject = selectedNode.getUserObject();
386 390
		if(userObject instanceof IGeoprocessPlugin){
387
			IGeoprocessPlugin metadata = 
391
			IGeoprocessPlugin metadata =
388 392
				(IGeoprocessPlugin)userObject;
389 393
			try {
390
				htmlPane.setPage(metadata.getHtmlDescription());
394
				htmlPane.setPage(metadata.getHtmlDescription().toString());
391 395
			} catch (IOException e) {
392 396
				htmlPane.setText("<p>Descripcion no disponible</p>");
393 397
			}
......
401 405
			getJButtonOpenGeop().setEnabled(false);
402 406
		}
403 407
	}
408
private class MyJEditorPane extends JEditorPane{
404 409

  
410
	public URL getPage() {
411
		return null;
412
	}
413

  
414
}
415

  
405 416
}  //  @jve:decl-index=0:visual-constraint="10,10"

Also available in: Unified diff