Revision 606

View differences:

org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/resources/about/wktraster-about.html
1
<html>
2
	<head>
3
	<style type="text/css">
4
	BODY { background-image: url(logo.png); background-repeat: no-repeat; background-position: 100% 0% }
5
	</style>
6
	</head>
7
	<body>	
8
		<h2>Soporte WKT Raster para gvSIG</h2>	
9
		<p><b>Prodevelop S.L.</b> ha incorporado el soporte al formato raster en 
10
		base de datos <b>PostGres</b></p>
11
		
12
		<p><b>Desarrollo:</b></p>
13
		
14
		<p>Director del proyecto:</p>
15
		<ul>
16
			<li>Miguel Montesinos Lajara</li>
17
		</ul>
18
		<p>Equipo de desarrollo:</p>
19
		<ul>
20
			<li>Nacho Brodin</li>
21
		</ul>
22
		
23
		<p><b>Colaboradores:</b></p>
24
		
25
		<p>Deimos:</p>
26
		<ul>
27
			<li>Jorge Arevalo</li>
28
		</ul>
29

  
30
		<p>Build Number de la extensi&oacute;n: 1</p>
31
		<center>
32
			<p><b><a href="http://www.prodevelop.es" title="Prodevelop">http://www.prodevelop.es</a></b></p>
33
		</center>
34
		
35
	</body>
36
</html>
0 37

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/TablesListItem.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.raster.postgis.app.postgisrasterclient.gui;
44

  
45
import javax.swing.JCheckBox;
46

  
47
import org.cresques.cts.IProjection;
48

  
49
import com.iver.andami.messages.NotificationManager;
50
import com.iver.cit.gvsig.addlayer.AddLayerDialog;
51
import com.iver.cit.gvsig.fmap.core.ICanReproject;
52
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
53
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
54
import com.iver.cit.gvsig.fmap.drivers.IConnection;
55
import com.iver.cit.gvsig.fmap.drivers.IVectorialDatabaseDriver;
56
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel;
57

  
58

  
59
/**
60
 * Utility class that represents a table list item as a selectable check box.
61
 *
62
 * @author jldominguez
63
 *
64
 */
65
public class TablesListItem extends JCheckBox {
66
	private static final long serialVersionUID = 1L;
67
	private String tableName = "";
68
    private IVectorialDatabaseDriver driver = null;
69
    private IConnection conn = null;
70
    private boolean activated = false;
71
    private CRSSelectPanel jPanelProj;
72

  
73
    public TablesListItem(String name, IVectorialDatabaseDriver drv, IConnection _conn) {
74
        tableName = name;
75
        setText(name);
76
        driver = drv;
77
        conn = _conn;
78
    }
79

  
80
    public void activate() {
81
        activated = true;
82
    }
83

  
84
    public boolean isActivated() {
85
        return activated;
86
    }
87

  
88
    /**
89
     * Tells whether this item prevents the wizard from being in a valid final state.
90
     * @return whether this item prevents the wizard from being in a valid final state.
91
     */
92
    public boolean disturbsWizardValidity() {
93
    	return false;
94
    }
95

  
96

  
97
    public String toString() {
98
        return tableName;
99
    }
100

  
101
    public String getTableName() {
102
        return tableName;
103
    }
104

  
105

  
106
    public CRSSelectPanel projectionPanel(String espView,
107
			FieldComboItem[] ids_ci, FieldComboItem[] geos_ci) {
108
		IProjection proj = AddLayerDialog.getLastProjection();
109
		if (driver instanceof ICanReproject) {
110
			try {
111
				DBLayerDefinition lyrDef = new DBLayerDefinition();
112
				lyrDef.setName(tableName);
113
				String[] tokens = tableName.split("\\u002E", 2);
114
				String schema = null;
115
				String tableName;
116
				if (tokens.length > 1) {
117
					schema = tokens[0];
118
					tableName = tokens[1];
119
				} else {
120
					tableName = tokens[0];
121
				}
122
				lyrDef.setSchema(schema);
123
				lyrDef.setTableName(tableName);
124
				if (ids_ci.length > 0){
125
					String fidField = ids_ci[0].toString();
126
					lyrDef.setFieldID(fidField);
127
				}
128
				if (geos_ci.length > 0){
129
					String geomField = geos_ci[0].toString();
130
					lyrDef.setFieldGeometry(geomField);
131
				}
132

  
133
				String strEPSG = espView;
134
				lyrDef.setSRID_EPSG(strEPSG);
135
				((ICanReproject) driver).setDestProjection(strEPSG);
136

  
137

  
138
				String srcProjection = ((ICanReproject) driver).getSourceProjection(conn,
139
						lyrDef);
140
				if (srcProjection != null && srcProjection.length() > 0
141
						&& !srcProjection.equals("-1")) {
142

  
143
					proj = CRSFactory.getCRS("EPSG:" + srcProjection);
144
				} else{
145
					proj = null;
146
				}
147
			} catch (Exception e) {
148
				NotificationManager.addInfo("Incorrect projection", e);
149
			}
150
		}
151
		return getJPanelProj(proj);
152
	}
153
    private CRSSelectPanel getJPanelProj(IProjection proj) {
154
//		if (jPanelProj == null) {
155
//			IProjection proj = CRSFactory.getCRS("EPSG:23030");
156
//			if (PluginServices.getMainFrame() != null) {
157
//				proj = FOpenDialog.getLastProjection();
158
//			}
159
			jPanelProj = CRSSelectPanel.getPanel(proj);
160

  
161
			jPanelProj.setTransPanelActive(true);
162
			jPanelProj.setBounds(new java.awt.Rectangle(210, 22, 280, 32));
163
			jPanelProj.setPreferredSize(new java.awt.Dimension(448,35));
164
			jPanelProj.addActionListener(new java.awt.event.ActionListener() {
165
				public void actionPerformed(java.awt.event.ActionEvent e) {
166
			        if (jPanelProj.isOkPressed()) {
167
			        	AddLayerDialog.setLastProjection(jPanelProj.getCurProj());
168
			        }
169
				}
170
			});
171

  
172
//		}
173

  
174
		return jPanelProj;
175
	}
176
}
0 177

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/PostGISRasterWizard.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.raster.postgis.app.postgisrasterclient.gui;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.Component;
23
import java.awt.event.ActionEvent;
24
import java.awt.event.ActionListener;
25
import java.sql.SQLException;
26
import java.util.ArrayList;
27

  
28
import javax.swing.DefaultListModel;
29
import javax.swing.ImageIcon;
30
import javax.swing.JButton;
31
import javax.swing.JComboBox;
32
import javax.swing.JOptionPane;
33
import javax.swing.JPanel;
34
import javax.swing.JScrollPane;
35
import javax.swing.ListSelectionModel;
36
import javax.swing.event.ListSelectionEvent;
37
import javax.swing.event.ListSelectionListener;
38

  
39
import org.apache.log4j.Logger;
40
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
41
import org.gvsig.raster.util.RasterUtilities;
42

  
43
import com.hardcode.driverManager.DriverLoadException;
44
import com.iver.andami.PluginServices;
45
import com.iver.andami.ui.mdiManager.IWindow;
46
import com.iver.cit.gvsig.SingleVectorialDBConnectionExtension;
47
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
48
import com.iver.cit.gvsig.fmap.drivers.DBException;
49
import com.iver.cit.gvsig.fmap.drivers.IConnection;
50
import com.iver.cit.gvsig.fmap.drivers.IVectorialDatabaseDriver;
51
import com.iver.cit.gvsig.fmap.drivers.db.utils.ConnectionWithParams;
52
import com.iver.cit.gvsig.fmap.drivers.db.utils.SingleVectorialDBConnectionManager;
53
import com.iver.cit.gvsig.fmap.layers.FLayer;
54
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
55
import com.iver.cit.gvsig.gui.WizardPanel;
56
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
57
import com.iver.utiles.swing.JPasswordDlg;
58
import com.prodevelop.cit.gvsig.vectorialdb.wizard.WizardVectorialDB;
59

  
60
/**
61
 * Wizard for adding a WKTRaster layer
62
 *  
63
 * @author Nacho Brodin (nachobrodin@gmail.org)
64
 */
65
public class WKTRasterWizard extends WizardPanel implements ActionListener, ListSelectionListener {
66
	private static final long serialVersionUID = 1L;
67

  
68
	private static Logger logger = Logger.getLogger(WizardVectorialDB.class.getName());
69
	protected IConnection conex = null;
70
	private ConnectionWithParams selectedDataSource = null;
71
	private JPanel namePanel = null;
72
	private JPanel tablesPanel = null;
73
	private JScrollPane tablesScrollPane = null;
74
	private AvailableTablesCheckBoxList tablesList = null;
75
	private JComboBox datasourceComboBox = null;
76
	private JButton dbButton = null;
77
	private BaseView view = null;
78

  
79
	public WKTRasterWizard() {
80
		super();
81
		initialize();
82
	}
83

  
84
	/**
85
	 * This method initializes this
86
	 *
87
	 * @return void
88
	 */
89
	private void initialize() {
90
		setTabName(PluginServices.getText(this, "WKT Raster"));
91
		setLayout(null);
92
		setSize(512, 478);
93

  
94
		IWindow iw = PluginServices.getMDIManager().getActiveWindow();
95

  
96
		if (iw == null) {
97
			return;
98
		}
99

  
100
		if (!(iw instanceof BaseView)) {
101
			return;
102
		}
103

  
104
		view = (BaseView) iw;
105
		setMapCtrl(view.getMapControl());
106
		add(getNamePanel(), null);
107
		loadVectorialDBDatasourcesCombo();
108

  
109
		add(getTablesPanel(), null);
110
	}
111

  
112
	protected void loadVectorialDBDatasourcesCombo() {
113
		getDatasourceComboBox().removeAllItems();
114

  
115
		getDatasourceComboBox().addItem(new ConnectionWithParams());
116

  
117
		ConnectionWithParams[] conn = SingleVectorialDBConnectionManager.instance()
118
		.getAllConnections();
119

  
120
		if (conn == null) {
121
			return;
122
		}
123

  
124
		for (int i = 0; i < conn.length; i++) {
125
			getDatasourceComboBox().addItem(conn[i]);
126
		}
127
	}
128

  
129
	/**
130
	 * Utility method to instantiate a IVectorialDataBaseDriver from its name.
131
	 *
132
	 * @param drvname driver's name
133
	 * @return a IVectorialDataBaseDriver
134
	 *
135
	 * @throws DriverLoadException
136
	 */
137
	public IVectorialDatabaseDriver getDriverFromName(String drvname)
138
	throws DriverLoadException {
139
		IVectorialDatabaseDriver resp =
140
			(IVectorialDatabaseDriver) LayerFactory.getDM().getDriver(drvname);
141
		return resp;
142
	}
143

  
144
	public void initWizard() {
145
	}
146

  
147
	public void execute() {
148
		SingleVectorialDBConnectionExtension.saveAllToPersistence();
149
	}
150

  
151
	/**
152
	 * Return FLayers if user performs multi selection.
153
	 */
154
	public FLayer getLayer() {
155
		String host = selectedDataSource.getHost();
156
		if(host.compareTo("localhost") == 0)
157
			host = "127.0.0.1";
158
		String port = selectedDataSource.getPort();
159
		String dbname = selectedDataSource.getDb();
160
		String user = selectedDataSource.getUser();
161
		String password = selectedDataSource.getPw();
162
		String table = null;
163
		String schema = null;
164
		
165
		TablesListItem[] selected = getSelectedTables();
166
		if(selected == null || selected.length == 0)
167
			return null;
168
		String[] tokens = selected[0].getTableName().split("\\u002E", 2);
169
		
170
		if (tokens.length > 1) {
171
			schema = tokens[0];
172
			table = tokens[1];
173
		} else {
174
			table = tokens[0];
175
		}
176
		
177
		String connString = null;
178
		if(schema == null)
179
			connString = "PG:host='" + host + "' port='" + port + "' dbname='" + dbname + "' user='" + user + "' password='" + password + "' table='" + table + "'";
180
		else
181
			connString = "PG:host='" + host + "' port='" + port + "' dbname='" + dbname + "' user='" + user + "' password='" + password + "' schema='" + schema + "' table='" + table + "'";
182
 
183
		try {
184
			return FLyrRasterSE.createLayer(RasterUtilities.getFormatedRasterFileName(connString), connString, null);
185
		} catch (LoadLayerException e) {
186
			e.printStackTrace();
187
			return null;
188
		}
189
	}
190
	
191
	/**
192
	 * Gets the list of selected tables
193
	 * @return
194
	 */
195
	protected TablesListItem[] getSelectedTables() {
196
		int count = tablesList.getModel().getSize();
197
		ArrayList<TablesListItem> resp = new ArrayList<TablesListItem>();
198

  
199
		for (int i = 0; i < count; i++) {
200
			TablesListItem item = (TablesListItem) tablesList.getModel()
201
			.getElementAt(i);
202

  
203
			if (item.isSelected()) {
204
				resp.add(item);
205
			}
206
		}
207

  
208
		return (TablesListItem[]) resp.toArray(new TablesListItem[0]);
209
	}
210

  
211
	/**
212
	 * This method initializes namePanel
213
	 *
214
	 * @return javax.swing.JPanel
215
	 */
216
	private JPanel getNamePanel() {
217
		if (namePanel == null) {
218
			namePanel = new JPanel();
219
			namePanel.setLayout(null);
220
			namePanel.setBounds(new java.awt.Rectangle(5, 5, 501, 51));
221
			namePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
222
					null, PluginServices.getText(this, "choose_connection"),
223
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
224
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
225
			namePanel.add(getDatasourceComboBox(), null);
226
			namePanel.add(getJdbcButton(), null);
227
		}
228

  
229
		return namePanel;
230
	}
231

  
232
	/**
233
	 * This method initializes tablesPanel
234
	 *
235
	 * @return javax.swing.JPanel
236
	 */
237
	private JPanel getTablesPanel() {
238
		if (tablesPanel == null) {
239
			tablesPanel = new JPanel();
240
			tablesPanel.setLayout(new BorderLayout());
241
			tablesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
242
					null, PluginServices.getText(this, "choose_table"),
243
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
244
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
245
			tablesPanel.setBounds(new java.awt.Rectangle(5, 55, 246, 191));
246
			tablesPanel.add(getTablesScrollPane(), java.awt.BorderLayout.CENTER);
247
		}
248

  
249
		return tablesPanel;
250
	}
251

  
252
	/**
253
	 * This method initializes settingsPanel
254
	 *
255
	 * @return javax.swing.JPanel
256
	 */
257

  
258
	/**
259
	 * This method initializes tablesScrollPane
260
	 *
261
	 * @return javax.swing.JScrollPane
262
	 */
263
	private JScrollPane getTablesScrollPane() {
264
		if (tablesScrollPane == null) {
265
			tablesScrollPane = new JScrollPane();
266
			tablesScrollPane.setViewportView(getTablesList());
267
		}
268

  
269
		return tablesScrollPane;
270
	}
271

  
272
	/**
273
	 * This method initializes tablesList
274
	 *
275
	 * @return javax.swing.JList
276
	 */
277
	private AvailableTablesCheckBoxList getTablesList() {
278
		if (tablesList == null) {
279
			tablesList = new AvailableTablesCheckBoxList(this);
280
			tablesList.addListSelectionListener(this);
281
			tablesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
282
		}
283

  
284
		return tablesList;
285
	}
286

  
287
	/**
288
	 * This method initializes layerNameTextField
289
	 *
290
	 * @return javax.swing.JTextField
291
	 */
292

  
293
	/**
294
	 * This method initializes jComboBox
295
	 *
296
	 * @return javax.swing.JComboBox
297
	 */
298
	protected JComboBox getDatasourceComboBox() {
299
		if (datasourceComboBox == null) {
300
			datasourceComboBox = new JComboBox();
301
			datasourceComboBox.setBounds(new java.awt.Rectangle(10, 20, 446, 21));
302
			datasourceComboBox.addActionListener(this);
303
		}
304

  
305
		return datasourceComboBox;
306
	}
307

  
308
	public void actionPerformed(ActionEvent arg0) {
309
		Object src = arg0.getSource();
310

  
311
		if (src == getDatasourceComboBox()) {
312
			Object sel_obj = getDatasourceComboBox().getSelectedItem();
313

  
314
			if (sel_obj == null) {
315
				return;
316
			}
317

  
318
			if (!(sel_obj instanceof ConnectionWithParams)) {
319
				return;
320
			}
321

  
322
			selectedDataSource = (ConnectionWithParams) sel_obj;
323

  
324
			if (selectedDataSource.isNull()) {
325
				updateTableList(selectedDataSource);
326
				//setEmptyPanels();
327
				return;
328
			}
329

  
330
			if (!selectedDataSource.isConnected()) {
331
				if (!tryToConnect(selectedDataSource)) {
332
					datasourceComboBox.setSelectedIndex(0);
333
					return;
334
				}
335
			}
336

  
337
			getDatasourceComboBox().repaint();
338
			updateTableList(selectedDataSource);
339

  
340
			// setEmptyPanels();
341
			return;
342
		}
343

  
344
		if (src == getJdbcButton()) {
345
			ConnectionWithParams sel = addNewConnection();
346

  
347
			if (sel != null) {
348
				loadVectorialDBDatasourcesCombo();
349
				getDatasourceComboBox().setSelectedItem(sel);
350
			}
351
		}
352
	}
353

  
354
	private boolean tryToConnect(ConnectionWithParams _cwp) {
355
		JPasswordDlg dlg = new JPasswordDlg();
356
		dlg.setLocationRelativeTo((Component)PluginServices.getMainFrame());
357
		String strMessage = PluginServices.getText(this, "conectar_jdbc");
358
		String strPassword = PluginServices.getText(this, "password");
359
		dlg.setMessage(strMessage + " [" + _cwp.getDrvName() + ", " +
360
				_cwp.getHost() + ", " + _cwp.getPort() + ", " + _cwp.getDb() +
361
				", " + _cwp.getUser() + "]. " + strPassword + "?");
362

  
363
		dlg.setVisible(true);
364

  
365
		String clave = dlg.getPassword();
366

  
367
		if (clave == null) {
368
			return false;
369
		}
370

  
371
		try {
372
			_cwp.connect(clave);
373
		}
374
		catch (DBException e) {
375
			showConnectionErrorMessage(e.getMessage());
376

  
377
			return false;
378
		}
379

  
380
		return true;
381
	}
382

  
383
	private void updateTableList(ConnectionWithParams src) {
384
		if (src.isNull()) {
385
			getTablesList().setModel(new DefaultListModel());
386
			getTablesScrollPane().setViewportView(tablesList);
387
			tablesScrollPane.updateUI();
388

  
389
			return;
390
		}
391

  
392
		conex = src.getConnection();
393

  
394
		String drvName = src.getDrvName();
395
		String dbName = "";
396

  
397
		IVectorialDatabaseDriver drv = null;
398

  
399
		try {
400
			dbName = src.getConnection().getCatalogName();
401
			drv = (IVectorialDatabaseDriver) LayerFactory.getDM().getDriver(drvName);
402
		}
403
		catch (Exception e) {
404
			logger.error("While getting driver instance: " + e.getMessage(), e);
405
		}
406

  
407
		if (!(drv instanceof IVectorialDatabaseDriver)) {
408
			logger.error(
409
					"Unexpected driver type (not a DefaultDBDriver driver)");
410

  
411
			return;
412
		}
413

  
414
		String[] tablnames = null;
415

  
416
		try {
417
			tablnames = drv.getTableNames(conex, dbName);
418
		}
419
		catch (DBException e) {
420
			logger.error("While getting table names: " + e.getMessage(), e);
421

  
422
			return;
423
		}
424

  
425
		DefaultListModel lmodel = new DefaultListModel();
426

  
427
		for (int i = 0; i < tablnames.length; i++) {
428
			try {
429
				if (drv.canRead(conex, tablnames[i])) {
430
					lmodel.addElement(new TablesListItem(tablnames[i], drv, conex));
431
				}
432
			} catch (SQLException e) {
433
				// if getTableNames works fine this exception should never be caught
434
				logger.error("While getting table names: " + e.getMessage(), e);
435
			}
436
		}
437

  
438
		getTablesList().setModel(lmodel);
439
		getTablesScrollPane().setViewportView(tablesList);
440
		tablesScrollPane.updateUI();
441
	}
442

  
443
	public void valueChanged(ListSelectionEvent arg0) {
444
		Object src = arg0.getSource();
445

  
446
		if (src == tablesList) {
447
			checkFinishable();
448
		}
449
	}
450

  
451
	private boolean validFormSettings() {
452
		int count = tablesList.getModel().getSize();
453

  
454
		boolean at_least_one = false;
455
		boolean resp = true;
456

  
457
		for (int i = 0; i < count; i++) {
458
			TablesListItem item = (TablesListItem) tablesList.getModel()
459
			.getElementAt(i);
460

  
461
			if (item.isSelected()) {
462
				at_least_one = true;
463
			}
464

  
465
			if (item.disturbsWizardValidity()) {
466
				resp = false;
467
			}
468
		}
469

  
470
		return (at_least_one && resp);
471
	}
472

  
473
	public void checkFinishable() {
474
		boolean finishable = validFormSettings();
475
		callStateChanged(finishable);
476
	}
477

  
478
	/**
479
	 * This method initializes jdbcButton
480
	 *
481
	 * @return javax.swing.JButton
482
	 */
483
	private JButton getJdbcButton() {
484
		if (dbButton == null) {
485
			dbButton = new JButton();
486
			dbButton.addActionListener(this);
487
			dbButton.setToolTipText(PluginServices.getText(this,
488
			"add_connection"));
489
			dbButton.setBounds(new java.awt.Rectangle(465, 20, 26, 21));
490

  
491
			String _file = createResourceUrl("images/jdbc.png").getFile();
492
			dbButton.setIcon(new ImageIcon(_file));
493
		}
494

  
495
		return dbButton;
496
	}
497

  
498
	/**
499
	 * Adds the connection panel
500
	 * @return
501
	 */
502
	private ConnectionWithParams addNewConnection() {
503
		ConnectionWithParams resp = null;
504

  
505
		WKTRasterDBConnectionParamsDialog newco = new WKTRasterDBConnectionParamsDialog();
506
		newco.showDialog();
507

  
508
		if (newco.isOkPressed()) {
509
			String _drvname = newco.getConnectionDriverName();
510
			String _host = newco.getConnectionServerUrl();
511
			String _port = newco.getConnectionPort();
512
			String _dbname = newco.getConnectionDBName();
513
			String _user = newco.getConnectionUser();
514
			String _pw = newco.getConnectionPassword();
515
			String _conn_usr_name = newco.getConnectionName();
516

  
517
			boolean hasToBeCon = newco.hasToBeConnected();
518

  
519
			try {
520
				resp = SingleVectorialDBConnectionManager.instance()
521
				.getConnection(_drvname,
522
						_user, _pw, _conn_usr_name, _host, _port, _dbname,
523
						hasToBeCon);
524
			}
525
			catch (DBException e) {
526
				showConnectionErrorMessage(e.getMessage());
527

  
528
				return null;
529
			}
530
			SingleVectorialDBConnectionExtension.saveAllToPersistence();
531
			return resp;
532
		}
533
		else {
534
			return null;
535
		}
536
	}
537

  
538
	 private java.net.URL createResourceUrl(String path) {
539
		 return getClass().getClassLoader().getResource(path);
540
	 }
541

  
542
	/**
543
	 * Shows an error message
544
	 * @param _msg
545
	 */
546
	private void showConnectionErrorMessage(String _msg) {
547
		 String msg = (_msg.length() > 300) ? "" : (": " + _msg);
548
		 String title = PluginServices.getText(this, "connection_error");
549
		 JOptionPane.showMessageDialog(this, title + msg, title,
550
				 JOptionPane.ERROR_MESSAGE);
551
	 }
552

  
553
}
0 554

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/AvailableTablesCheckBoxList.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.raster.postgis.app.postgisrasterclient.gui;
44

  
45
import java.awt.Component;
46
import java.awt.event.MouseAdapter;
47
import java.awt.event.MouseEvent;
48

  
49
import javax.swing.JList;
50
import javax.swing.JOptionPane;
51
import javax.swing.ListCellRenderer;
52
import javax.swing.ListSelectionModel;
53
import javax.swing.UIManager;
54
import javax.swing.border.Border;
55
import javax.swing.border.EmptyBorder;
56

  
57
import org.apache.log4j.Logger;
58

  
59
import com.iver.andami.PluginServices;
60

  
61

  
62
/**
63
 * Utility class to keep the list of available tables.
64
 *
65
 * @author jldominguez
66
 *
67
 */
68
public class AvailableTablesCheckBoxList extends JList {
69
	private static final long serialVersionUID = 1L;
70
	protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
71
    private static Logger logger = Logger.getLogger(AvailableTablesCheckBoxList.class.getName());
72
    private WKTRasterWizard parent = null;
73
    private TablesListItem actingTable = null;
74

  
75
    public AvailableTablesCheckBoxList(WKTRasterWizard p) {
76
        parent = p;
77

  
78
        setCellRenderer(new CellRenderer());
79

  
80
        addMouseListener(new MouseAdapter() {
81
                public void mousePressed(MouseEvent e) {
82
                    int index = locationToIndex(e.getPoint());
83

  
84
                    if (index == -1) {
85
                        return;
86
                    }
87

  
88
                    actingTable = (TablesListItem) getModel().getElementAt(index);
89

  
90
                    if ((e.getClickCount() == 2) || (e.getX() < 15)) {
91
                        if (!actingTable.isActivated()) {
92
                            actingTable.activate();
93
                        }
94

  
95
                        actingTable.setSelected(!actingTable.isSelected());
96

  
97
                        repaint();
98
                    }
99

  
100
                    try {
101
                        //parent.setSettingsPanels(actingTable);
102
                        parent.checkFinishable();
103
                    }
104
                    catch (Exception e1) {
105
                        actingTable.setSelected(false);
106
                        logger.error("While setting selected table: " +
107
                            e1.getMessage(), e1);
108
                        showConnectionErrorMessage(e1.getMessage());
109
                    }
110
                }
111
            });
112

  
113
        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
114
    }
115

  
116
    private void showConnectionErrorMessage(String _msg) {
117
        String msg = (_msg.length() > 300) ? "" : (": " + _msg);
118
        String title = PluginServices.getText(this, "connection_error");
119
        JOptionPane.showMessageDialog(this, title + msg, title,
120
            JOptionPane.ERROR_MESSAGE);
121
    }
122

  
123
    protected class CellRenderer implements ListCellRenderer {
124
        public Component getListCellRendererComponent(JList list, Object value,
125
            int index, boolean isSelected, boolean cellHasFocus) {
126
            TablesListItem checkbox = (TablesListItem) value;
127
            checkbox.setBackground(isSelected ? getSelectionBackground()
128
                                              : getBackground());
129
            checkbox.setForeground(isSelected ? getSelectionForeground()
130
                                              : getForeground());
131
            checkbox.setEnabled(isEnabled());
132
            checkbox.setFont(getFont());
133
            checkbox.setFocusPainted(false);
134
            checkbox.setBorderPainted(true);
135
            checkbox.setBorder(isSelected
136
                ? UIManager.getBorder("List.focusCellHighlightBorder")
137
                : noFocusBorder);
138

  
139
            return checkbox;
140
        }
141
    }
142
}
0 143

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/FieldComboItem.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package org.gvsig.raster.postgis.app.postgisrasterclient.gui;
44

  
45

  
46
/**
47
 * Utility class to deal with combo boxes.
48
 *
49
 * @author jldominguez
50
 *
51
 */
52
public class FieldComboItem {
53
    private String name = "";
54

  
55
    public FieldComboItem(String _name) {
56
        name = _name;
57
    }
58

  
59
    public String toString() {
60
        return name;
61
    }
62
}
0 63

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/gui/PostGISRasterDBConnectionParamsDialog.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.raster.postgis.app.postgisrasterclient.gui;
20

  
21
import com.prodevelop.cit.gvsig.vectorialdb.wizard.VectorialDBConnectionParamsDialog;
22

  
23
/**
24
 * Dialog for introduce database parameters
25
 *  
26
 * @author Nacho Brodin (nachobrodin@gmail.org)
27
 */
28
public class WKTRasterDBConnectionParamsDialog extends VectorialDBConnectionParamsDialog {
29
	private static final long serialVersionUID = 1L;
30

  
31
	protected String[] getDriverNames() {
32
		return new String[]{"PostGIS JDBC Driver"};
33
	}
34

  
35
}
0 36

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/src/main/java/org/gvsig/raster/postgis/app/postgisrasterclient/PostGISRasterExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.raster.postgis.app.postgisrasterclient;
20

  
21
import org.gvsig.raster.postgis.app.postgisrasterclient.gui.PstGISRasterWizard;
22

  
23
import com.iver.andami.PluginServices;
24
import com.iver.andami.plugins.Extension;
25
import com.iver.cit.gvsig.About;
26
import com.iver.cit.gvsig.AddLayer;
27
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
28

  
29
/**
30
 * Entry point for PostGISRaster extension
31
 *  
32
 * @author Nacho Brodin (nachobrodin@gmail.org)
33
 */
34
public class PostGISRasterExtension extends Extension {
35
	/**
36
	 * Initializes the wizard panel
37
	 *
38
	 */
39
	public void initialize() {
40
    	AddLayer.addWizard(PostGISRasterWizard.class);
41
    	initializeIcons();
42
	}
43

  
44
	/**
45
	 * @see com.iver.andami.plugins.IExtension#postInitialize()
46
	 */
47
	@Override
48
	public void postInitialize() {
49
		final About about = (About) PluginServices.getExtension(About.class);
50
		final FPanelAbout panelAbout = about.getAboutPanel();
51
		final java.net.URL aboutURL = getClass().getClassLoader().getResource("about/wktraster-about.html");
52
		panelAbout.addAboutUrl("PostGIS Raster", aboutURL);
53
	}
54

  
55
	public void execute(String actionCommand) {
56
	}
57

  
58
	public boolean isEnabled() {
59
		return true;
60
	}
61

  
62
	public boolean isVisible() {
63
		return false;
64
	}
65

  
66
	void initializeIcons(){
67
	
68
	}
69
}
0 70

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
		<!-- Estructure for the extension -->
8
		<fileSet>
9
			<directory>src/main/resources</directory>
10
			<outputDirectory>${extension.install.dir.name}
11
			</outputDirectory>
12
		</fileSet>
13
	</fileSets>
14
	<dependencySets>
15
		<dependencySet>
16
			<outputDirectory>${extension.install.dir.name}/${library-dir}
17
			</outputDirectory>
18
			<includes>
19
				<include>org.gvsig:org.gvsig.raster.postgis.app.postgisrasterclient:jar</include>
20
				<include>org.gvsig:org.gvsig.raster.postgis.io:jar</include>
21
			</includes>
22
		</dependencySet>
23
	</dependencySets>
24
</assembly>
0 25

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
    <modelVersion>4.0.0</modelVersion>
6
    <groupId>org.gvsig</groupId>
7
    <artifactId>org.gvsig.raster.postgis.app</artifactId>
8
    <packaging>pom</packaging>
9
    <version>2.0.0-SNAPSHOT</version>
10
    <name>org.gvsig.raster.postgis.app</name>
11
    <description>PostGIS raster application</description>
12
    <url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.raster.app/${pom.version}</url>
13
    <parent>
14
        <groupId>org.gvsig</groupId>
15
        <artifactId>org.gvsig.maven.base.extension.pom</artifactId>
16
        <version>1.0.7-SNAPSHOT</version>
17
    </parent>
18

  
19
    <scm>
20
        <connection>scm:svn:https://svn.forge.osor.eu/svn/gvsig-raster/org.gvsig.raster.app/trunk/org.gvsig.raster.app</connection>
21
        <developerConnection>scm:svn:https://svn.forge.osor.eu/svn/gvsig-raster/org.gvsig.raster.app/trunk/org.gvsig.raster.app</developerConnection>
22
        <url>https://forge.osor.eu/plugins/scmsvn/viewcvs.php/org.gvsig.raster.app/trunk/org.gvsig.raster.app?root=gvsig-raster</url>
23
    </scm>
24

  
25
    <developers>
26
        <developer>
27
            <id>nbrodin</id>
28
            <name>Nacho Brodin</name>
29
            <email>nachobrodin@gmail.com</email>
30
            <roles>
31
                <role>Architect</role>
32
                <role>Developer</role>
33
            </roles>
34
        </developer>
35
    </developers>
36

  
37
    <distributionManagement>
38
        <site>
39
            <id>gvsig-repository</id>
40
            <url>scp://shell.forge.osor.eu/home/groups/gvsig-desktop/www/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.raster.app/${pom.version}</url>
41
        </site>
42
    </distributionManagement>
43
    <repositories>
44
        <repository>
45
            <id>gvsig-public-http-repository</id>
46
            <name>gvSIG maven public HTTP repository</name>
47
            <url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/maven-repository</url>
48
            <releases>
49
                <enabled>true</enabled>
50
                <updatePolicy>daily</updatePolicy>
51
                <checksumPolicy>warn</checksumPolicy>
52
            </releases>
53
            <snapshots>
54
                <enabled>true</enabled>
55
                <updatePolicy>daily</updatePolicy>
56
                <checksumPolicy>warn</checksumPolicy>
57
            </snapshots>
58
        </repository>
59
    </repositories>
60
    <build>
61
        <plugins>
62
            <plugin>
63
                <groupId>org.apache.maven.plugins</groupId>
64
                <artifactId>maven-release-plugin</artifactId>
65
                <configuration>
66
                    <tagBase>https://svn.forge.osor.eu/svn/gvsig-raster/org.gvsig.raster.app/tags</tagBase>
67
                </configuration>
68
            </plugin>
69
        </plugins>
70
    </build>
71
    <dependencyManagement>
72
        <dependencies>
73
            <dependency>
74
                <groupId>org.gvsig</groupId>
75
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
76
                <type>pom</type>
77
                <version>2.0.1-SNAPSHOT</version>
78
                <scope>import</scope>
79
            </dependency>
80
        </dependencies>
81
    </dependencyManagement>
82
    <dependencies>
83
        <dependency>
84
            <groupId>org.gvsig</groupId>
85
            <artifactId>org.gvsig.andami</artifactId>
86
            <scope>compile</scope>
87
        </dependency>
88
        <dependency>
89
            <groupId>org.gvsig</groupId>
90
            <artifactId>org.gvsig.i18n</artifactId>
91
            <scope>compile</scope>
92
        </dependency>
93
        <dependency>
94
            <groupId>org.gvsig</groupId>
95
            <artifactId>org.gvsig.tools.lib</artifactId>
96
            <scope>compile</scope>
97
        </dependency>
98
        <dependency>
99
            <groupId>org.slf4j</groupId>
100
            <artifactId>slf4j-api</artifactId>
101
            <scope>compile</scope>
102
        </dependency>
103
        <dependency>
104
            <groupId>org.slf4j</groupId>
105
            <artifactId>slf4j-log4j12</artifactId>
106
            <scope>runtime</scope>
107
        </dependency>
108
    </dependencies>
109
    <modules>
110
        <module>org.gvsig.raster.postgis.app.postgisrasterclient</module>
111
    </modules>
112
</project>
0 113

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                       http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<groupId>org.gvsig</groupId>
5
	<artifactId>org.gvsig.raster.postgis</artifactId>
6
	<packaging>pom</packaging>
7
	<version>2.0.0-SNAPSHOT</version>
8
	<name>org.gvsig.raster.postgis</name>
9
	<description>PostGIS raster adapter</description>
10
	<inceptionYear>2011</inceptionYear>
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>gvsig-base-pom</artifactId>
14
        <version>2.0-SNAPSHOT</version>
15
    </parent>	
16
	<distributionManagement>
17
		<site>
18
			<id>gvsig-repository</id>
19
			<url>${site-repository}/</url>
20
		</site>
21
	</distributionManagement>
22

  
23
	<properties>
24
		<build-dir>${basedir}/../..</build-dir>
25
	</properties>
26
	<modules>
27
		<module>org.gvsig.raster.postgis.io</module>
28
		<module>org.gvsig.raster.postgis.app</module>
29
	</modules>
30
</project>
0 31

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.raster.postgis/trunk/org.gvsig.raster.postgis/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.raster.postgis</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
	</buildSpec>
9
	<natures>
10
	</natures>
11
</projectDescription>
0 12

  

Also available in: Unified diff