Revision 36826

View differences:

tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/filters/AbstractFilter.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
/*
43
* CVS MESSAGES:
44
*
45
* $Id$
46
* $Log$
47
* Revision 1.1  2006-01-10 09:32:49  jorpiell
48
* Se ha echo un commit de las versiones modificadas del catalogo y del gazetteer usando el Poseidon. Se han renombrado algunas clases por considerar que tenian un nombre confuso y se han cambiado algunas relaciones entre clases (con la intenci?n de separar GUI de la parte de control). Han habido clases que no han sido tocadas, pero como han sido formateadas usando el Poseidon TODAS las CLASES del proyecto han cambiado de versi?n.
49
*
50
* Revision 1.1  2005/12/22 08:31:43  jorpiell
51
* Aqui tambien se han producido muchos cambis, porque hemos acabado de cambiar la estructura del cat?logo: Se han creado todas las clases "XXXMessages", que sacan toda la parte de los mensajes de los drivers. Ademas se ha incluido en "CatalogClient" la operaci?n "getCapabilities", que libera a la interfaz de algunas operaciones que hac?a anteriormente.
52
*
53
*
54
*/
55
package org.gvsig.gazetteer.filters;
56

  
57
/**
58
 * This class must to be inherited by all the classes
59
 * that implements a gazetteer filter
60
 * 
61
 */
62
public abstract class AbstractFilter implements IFilter {
63

  
64
/**
65
 * It envolves the different words of a phrase with "*"
66
 * 
67
 * 
68
 * @return the new String
69
 * @param name Query String
70
 * @param option Exact, anY or All.
71
 */
72
    public String formatName(String name, String option) {        
73
            if (!(option.equals("E"))){
74
                String[] split = name.split(" ");
75
                String aux = "";
76
                for (int i=0 ; i<split.length ; i++){
77
                    aux = aux + "*" + split[i] + "* ";
78
                }
79
                return aux;
80
            }
81
            return "*" + name + "*";
82
            
83
    } 
84
 }
0 85

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/filters/IFilter.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package org.gvsig.gazetteer.filters;
43
import org.gvsig.gazetteer.querys.GazetteerQuery;
44
/**
45
 * This interface contains the common methods for the gazetteer
46
 * filters
47
 * 
48
 * 
49
 * @author Jorge Piera Llodra (piera_jor@gva.es)
50
 */
51
public interface IFilter {
52
/**
53
 * 
54
 * 
55
 * 
56
 * @return 
57
 * @param query 
58
 */
59
    public String getQuery(GazetteerQuery query);
60
}
61
//Return the query that will be used for the driver
62

  
63

  
0 64

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/GazetteerClient.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer;
43
import org.gvsig.catalog.DiscoveryServiceClient;
44
import org.gvsig.gazetteer.drivers.GazetteerCapabilities;
45
import org.gvsig.gazetteer.drivers.IGazetteerServiceDriver;
46
import org.gvsig.gazetteer.querys.Feature;
47
import org.gvsig.gazetteer.querys.FeatureType;
48
import org.gvsig.gazetteer.querys.FeatureTypeAttribute;
49
import org.gvsig.gazetteer.querys.GazetteerQuery;
50

  
51

  
52
/**
53
 * This class represents a gazetteer client. It must be created to
54
 * use the gazetteer service 
55
 * @author Jorge Piera Llodra (piera_jor@gva.es)
56
 */
57
public class GazetteerClient extends DiscoveryServiceClient{
58
	
59
	public GazetteerClient(String uri, IGazetteerServiceDriver driver) {
60
		super(uri, driver);		
61
	}
62

  
63
	/**
64
	 * @return the feature types
65
	 * @throws Exception 
66
	 */
67
	public FeatureType[] getFeatureTypes() throws Exception {
68
		return ((GazetteerCapabilities)getCapabilities()).getFeatureTypes();
69
	}
70

  
71
	/**
72
	 * This method makes the describeFeatureType
73
	 * operation
74
	 * @param featureName
75
	 * Feature name
76
	 * @return
77
	 * @throws Exception 
78
	 */
79
	public FeatureTypeAttribute[] describeFeatureType(String featureName) throws Exception{
80
		return ((IGazetteerServiceDriver)getDriver()).describeFeatureType(getUri(), featureName);
81
	}
82
	
83
	/**
84
	 * @return if the describeFeatureType operation is
85
	 * supported by the driver
86
	 */
87
	public boolean isDescribeFeatureTypeNeeded(){
88
		return ((IGazetteerServiceDriver)getDriver()).isDescribeFeatureTypeNeeded();
89
	}
90

  
91
	/**
92
	 * This method implements the getFeature operation
93
	 * @return 
94
	 * A result collection
95
	 * @param query 
96
	 * The results query
97
	 * @throws Exception 
98
	 */
99
	public Feature[] getFeature(GazetteerQuery query) throws Exception {        
100
		return ((IGazetteerServiceDriver)getDriver()).getFeature(getUri(), query);
101
	} 	
102

  
103
	/**
104
	 * This method is used to create a new Query
105
	 * @return 
106
	 */
107
	public GazetteerQuery createNewQuery() {        
108
		return new GazetteerQuery();   
109
	} 	
110
	
111
	/**
112
	 * @return the projection
113
	 */
114
	public String getProjection() {
115
		return ((IGazetteerServiceDriver)getDriver()).getProjection();
116
	}
117

  
118
	/**
119
	 * @param projection the projection to set
120
	 */
121
	public void setProjection(String projection) {
122
		((IGazetteerServiceDriver)getDriver()).setProjection(projection);
123
	} 
124
}
0 125

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/ui/serverconnect/ServerConnectDialog.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer.ui.serverconnect;
43
import org.gvsig.catalog.utils.Frames;
44

  
45
/**
46
 * This class implements the JFrame for the server
47
 * connect panel that will be used when the gazetteer
48
 * client is runned without gvSIG. It also implements
49
 * the window listener that closes the application when
50
 * the window is closed.
51
 * @author Jorge Piera Llodra (piera_jor@gva.es)
52
 */
53
public class ServerConnectDialog extends org.gvsig.catalog.ui.serverconnect.ServerConnectDialog{
54
	private static final long serialVersionUID = -6457336150268592182L;
55

  
56
	public  ServerConnectDialog() {        
57
		super();       
58
		initialize();
59
	} 
60

  
61
	/**
62
	 * This method initializes jDialog
63
	 */
64
	protected void initialize() {        
65
		Frames.centerFrame(this, 625, 290);
66
		this.setTitle("Metadata catalog");
67
		setResizable(false);
68
		setName("serverConnect");
69
		getContentPane().add(new ServerConnectDialogPanel(
70
				this));
71
		addWindowListener(this);
72
		setVisible(true);
73
	} 	
74
}
0 75

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/ui/serverconnect/ServerConnectDialogPanel.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer.ui.serverconnect;
43
import java.awt.BorderLayout;
44
import java.awt.Cursor;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.io.BufferedReader;
48
import java.io.File;
49
import java.io.FileNotFoundException;
50
import java.io.FileReader;
51
import java.io.IOException;
52
import java.util.Iterator;
53
import java.util.TreeMap;
54

  
55
import javax.swing.JFrame;
56
import javax.swing.JPanel;
57

  
58
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
59
import org.gvsig.catalog.utils.CatalogConstants;
60
import org.gvsig.gazetteer.GazetteerClient;
61
import org.gvsig.gazetteer.GazetteerLocator;
62
import org.gvsig.gazetteer.GazetteerManager;
63
import org.gvsig.gazetteer.drivers.IGazetteerServiceDriver;
64
import org.gvsig.gazetteer.ui.search.SearchDialog;
65
import org.gvsig.i18n.Messages;
66
import org.gvsig.utils.swing.jcomboServer.ServerData;
67

  
68

  
69

  
70
/**
71
 * It implements the Jpanel thas has the events control
72
 * for the connection panel. It is composed by some buttons
73
 * and a panel.
74
 * @author Jorge Piera Llodra (piera_jor@gva.es)
75
 */
76
public class ServerConnectDialogPanel extends JPanel implements ActionListener {
77
	private static final GazetteerManager gazetteerManager = GazetteerLocator.getGazetteerManager();
78
	private static final long serialVersionUID = 7022169996238047820L;
79
	private static TreeMap serverList = new TreeMap();
80
	private ServerConnectPanel controlsPanel = null;
81
	private JFrame parent = null;
82
	protected GazetteerClient client = null;
83
	protected String serversFile = "servers/GazetteerServers.txt";
84
	protected String currentServer = "";
85
	private ConnectThread connectThread = null;
86

  
87
	/**
88
	 * Constructor
89
	 * @param parent 
90
	 */
91
	public  ServerConnectDialogPanel(JFrame parent) {
92
		this.parent = parent;
93
		this.setLayout(new BorderLayout());
94
		add(getControlsPanel(),BorderLayout.CENTER);
95
		//Loads the servers
96
		loadServerList(serversFile);
97
		//Load the protocols
98
		controlsPanel.loadDrivers(
99
				gazetteerManager.getDrivers());
100
		//Load the first protocol
101
		controlsPanel.setProtocol(controlsPanel.getServer().getServiceSubType());
102
	} 
103

  
104
	/**
105
	* @return the main panel
106
	 */
107
	public ServerConnectPanel getControlsPanel() {        
108
		if (controlsPanel == null) {
109
			controlsPanel = new ServerConnectPanel();
110
			controlsPanel.addActionListener(this);
111
			controlsPanel.enableSearchButton(false);
112
		}
113
		return controlsPanel;
114
	} 
115
	
116
	/**
117
	 * It adds a server in the TreeMap Object
118
	 * @param server 
119
	 */
120
	protected static void addTreeMapServer(ServerData server) {        
121
		if (ServerConnectDialogPanel.serverList == null) {
122
			ServerConnectDialogPanel.serverList = new TreeMap();
123
		}
124
		serverList.put(server.getServerAddress(), server);
125
	} 
126

  
127
	/**
128
	 * This method loads a server list in the combo
129
	 * @param sfile 
130
	 */
131
	private void loadServerList(String sfile) {        
132
		loadServersFromFile(sfile);
133
		Iterator iter = serverList.keySet().iterator();
134
		while (iter.hasNext()) {
135
			ServerData server = (ServerData) serverList.get((String) iter.next());
136
			controlsPanel.addServer(server);
137
		}		
138
	} 
139

  
140
	/**
141
	 * It loads a server list from a text file
142
	 * @param sfile 
143
	 * File that contains the rervers
144
	 */
145
	private void loadServersFromFile(String sfile) {        
146
		File file = null;
147
		try {
148
			file = new File(sfile);
149
			if (file.exists()) {
150
				BufferedReader fr = new BufferedReader(new FileReader(file));
151
				String s;
152
				while ((s = fr.readLine()) != null) {
153
					addTreeMapServer(new ServerData(s,"",""));
154
				}
155
			} else {
156
				System.out.println("No se encuentra el fichero '" +
157
						file.getPath() + "'");
158
			}
159
		} catch (FileNotFoundException e) {
160
			System.out.println("No se encuentra el fichero '" + file.getPath() +
161
			"'");
162
			//e.printStackTrace();
163
		} catch (IOException e) {
164
			System.out.println("Error de entrada salida en la lectura del fichero");
165
			//e.printStackTrace();
166
		}
167
	} 
168
	
169
	/*
170
	 * (non-Javadoc)
171
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
172
	 */
173
	public void actionPerformed(ActionEvent e) {        
174
		if (e.getActionCommand().compareTo(CatalogConstants.CONNECT_BUTTON_ACTION_COMMAND)==0) {
175
			connectButtonActionPerformed();
176
		}
177
		if (e.getActionCommand().compareTo(CatalogConstants.SEARCH_BUTTON_ACTION_COMMAND)==0) {
178
			searchButtonActionPerformed();
179
		}
180
		if (e.getActionCommand().compareTo(CatalogConstants.CLOSE_BUTTON_ACTION_COMMAND)==0) {
181
			closeButtonActionPerformed();
182
		}
183
		if (e.getActionCommand().compareTo(CatalogConstants.PROTOCOL_COMBO_ACTION_COMMAND)==0){
184
			
185
		}
186
		if (e.getActionCommand().compareTo(CatalogConstants.SERVER_COMBO_ACTION_COMMAND)==0) {
187
			controlsPanel.updateProtocol();
188
		}
189
	} 
190

  
191
	/**
192
	 * Action when the search button is clicked
193
	 */
194
	protected void searchButtonActionPerformed() {        
195
		setEnabled(false);
196
		new SearchDialog(client,parent);
197
	} 
198

  
199
	/**
200
	 * It is thrown the the connect button is clicked
201
	 */
202
	protected void connectButtonActionPerformed() {        
203
		controlsPanel.enableSearchButton(false);		
204
		//Create a new Gazetteer client
205
		client = new GazetteerClient(controlsPanel.getServerAddress(),
206
				(IGazetteerServiceDriver)controlsPanel.getDriver());
207
		if (connectThread != null){
208
			connectThread.stop();
209
		}
210
		connectThread = new ConnectThread();
211
		setCursor(new Cursor(Cursor.WAIT_CURSOR));
212
	} 
213

  
214
	/**
215
	 *  * It is thrown the the close button is clicked
216
	 */
217
	protected void closeButtonActionPerformed() {        
218
		parent.setVisible(false);
219
		System.exit(0);
220
	} 
221

  
222
	/**
223
	 * @return Returns the serversFile.
224
	 */
225
	public String getServersFile() {        
226
		return serversFile;
227
	} 
228

  
229
	/**
230
	 * @param serversFile The serversFile to set.
231
	 */
232
	public void setServersFile(String serversFile) {        
233
		this.serversFile = serversFile;
234
	} 
235

  
236
	/**
237
	 * @return Returns the currentServer.
238
	 */
239
	public String getCurrentServer() {        
240
		return currentServer;
241
	} 
242

  
243
	/**
244
	 * @return Returns the client.
245
	 */
246
	public GazetteerClient getCliente() {        
247
		return client;
248
	} 
249
	
250
	/**
251
	 * This class is used to manage the searches.
252
	 * It contains method to start and to stop a thread. It is
253
	 * necessary to create because "stop" method (for the Thread class)
254
	 * is deprecated.
255
	 * 
256
	 * 
257
	 * @author Jorge Piera Llodra (piera_jor@gva.es)
258
	 */
259
	private class ConnectThread implements Runnable {
260
		volatile Thread myThread = null;
261

  
262
		public  ConnectThread() {        
263
			myThread = new Thread(this);
264
			myThread.start();
265
		} 
266

  
267
		public void stop(){
268
			myThread.stop();
269
		}
270
		/*
271
		 * (non-Javadoc)
272
		 * @see java.lang.Runnable#run()
273
		 */
274
		public void run() {        
275
			try {
276
				DiscoveryServiceCapabilities capabilities = client.getCapabilities();
277
				if (capabilities.isAvailable()){
278
					controlsPanel.enableSearchButton(true);
279
					currentServer = controlsPanel.getServerAddress();
280
					searchButtonActionPerformed();
281
				}	
282
				setCursor(new Cursor(Cursor.DEFAULT_CURSOR));   
283
				controlsPanel.setServerReply(capabilities.getServerMessage());				
284
			} catch (Exception e) {
285
				controlsPanel.setServerReply(Messages.getText(e.toString()));
286
				e.printStackTrace();
287
			}	
288
		}
289
	}	
290
}
0 291

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/ui/serverconnect/ServerConnectPanel.java
1
package org.gvsig.gazetteer.ui.serverconnect;
2

  
3
import org.gvsig.gazetteer.GazetteerLocator;
4
import org.gvsig.gazetteer.GazetteerManager;
5
import org.gvsig.gazetteer.drivers.IGazetteerServiceDriver;
6

  
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id: ServerConnectPanel.java 605 2007-10-18 10:57:03 +0000 (Thu, 18 Oct 2007) jpiera $
51
 * $Log$
52
 * Revision 1.1.2.5  2007/07/24 11:25:42  jorpiell
53
 * The registers has been refactorized
54
 *
55
 * Revision 1.1.2.4  2007/07/24 09:55:31  jorpiell
56
 * Add the default servers
57
 *
58
 * Revision 1.1.2.3  2007/07/13 12:00:35  jorpiell
59
 * Add the posibility to add a new panel
60
 *
61
 * Revision 1.1.2.2  2007/07/11 13:01:50  jorpiell
62
 * Catalog UI updated
63
 *
64
 * Revision 1.1.2.1  2007/07/10 11:18:04  jorpiell
65
 * Added the registers
66
 *
67
 *
68
 */
69
/**
70
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
71
 */
72
public class ServerConnectPanel extends org.gvsig.catalog.ui.serverconnect.ServerConnectPanel{
73
	private static final GazetteerManager gazetteerManager = GazetteerLocator.getGazetteerManager();
74
	
75
	public ServerConnectPanel(){
76
		super();
77
		setDatabaseVisible(false);	
78
		setServerPropertiesButtonVisible(false);
79
	}
80
	
81
	/**
82
	 * Select a concrete protocol
83
	 * @param protocol
84
	 * Protocol to select
85
	 */
86
	public void setProtocol(String protocol){
87
		IGazetteerServiceDriver driver = gazetteerManager.getDriver(protocol);
88
		if (driver != null){
89
			protocolCombo.setSelectedItem(driver);
90
		}
91
	}
92
}
0 93

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/ui/showresults/ShowResultsDialog.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer.ui.showresults;
43
import java.awt.Dimension;
44
import java.awt.event.WindowEvent;
45
import java.awt.event.WindowListener;
46

  
47
import javax.swing.JDialog;
48

  
49
import org.gvsig.catalog.utils.Frames;
50
import org.gvsig.gazetteer.GazetteerClient;
51
import org.gvsig.gazetteer.querys.Feature;
52
import org.gvsig.gazetteer.querys.GazetteerQuery;
53

  
54

  
55
/**
56
 * DOCUMENT ME!
57
 * 
58
 * 
59
 * @author luisw
60
 */
61
public class ShowResultsDialog extends JDialog implements WindowListener {
62

  
63
/**
64
 * 
65
 * 
66
 */
67
    int recordsByPage;
68

  
69
/**
70
 * <p></p>
71
 * 
72
 * 
73
 */
74
    protected org.gvsig.gazetteer.ui.showresults.ShowResultsDialogPanel showResultsDialogPanel = null;
75

  
76
/**
77
 * Crea un nuevo ShowResultsDialog.
78
 * @param client Gazetteer Client
79
 * @param features The found features
80
 */
81
    public  ShowResultsDialog(GazetteerClient client, Feature[] features, int recordsByPage,GazetteerQuery query) {        
82
        super();
83
        this.recordsByPage = recordsByPage;
84
        initialize(client,features,query);
85
    } 
86

  
87
/**
88
 * This method initializes jDialog
89
 * 
90
 * 
91
 * @param gazetteerClient 
92
 * @param features 
93
 */
94
    private void initialize(org.gvsig.gazetteer.GazetteerClient gazetteerClient, Feature[] features, GazetteerQuery query) {        
95
        Frames.centerFrame(this, 420, 257);
96
        this.setSize(new Dimension(420, 257));
97
        this.setTitle("Cliente Gazetteer");
98
        ShowResultsDialogPanel panel = new ShowResultsDialogPanel(gazetteerClient,
99
                features, recordsByPage, query);
100
        panel.setParent(this);
101
        getContentPane().add(panel);
102
        this.setVisible(true);
103
    } 
104
/* (non-Javadoc)
105
     * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
106
     */
107

  
108
/**
109
 * 
110
 * 
111
 * 
112
 * @param e 
113
 */
114
    public void windowActivated(WindowEvent e) {        
115
        // TODO Auto-generated method stub
116
    } 
117
/* (non-Javadoc)
118
     * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
119
     */
120

  
121
/**
122
 * 
123
 * 
124
 * 
125
 * @param e 
126
 */
127
    public void windowClosed(WindowEvent e) {        
128
        // TODO Auto-generated method stub
129
    } 
130
/* (non-Javadoc)
131
     * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
132
     */
133

  
134
/**
135
 * 
136
 * 
137
 * 
138
 * @param e 
139
 */
140
    public void windowClosing(WindowEvent e) {        
141
        // TODO Auto-generated method stub
142
    } 
143
/* (non-Javadoc)
144
     * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
145
     */
146

  
147
/**
148
 * 
149
 * 
150
 * 
151
 * @param e 
152
 */
153
    public void windowDeactivated(WindowEvent e) {        
154
        // TODO Auto-generated method stub
155
    } 
156
/* (non-Javadoc)
157
     * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
158
     */
159

  
160
/**
161
 * 
162
 * 
163
 * 
164
 * @param e 
165
 */
166
    public void windowDeiconified(WindowEvent e) {        
167
        // TODO Auto-generated method stub
168
    } 
169
/* (non-Javadoc)
170
     * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
171
     */
172

  
173
/**
174
 * 
175
 * 
176
 * 
177
 * @param e 
178
 */
179
    public void windowIconified(WindowEvent e) {        
180
        // TODO Auto-generated method stub
181
    } 
182
/* (non-Javadoc)
183
     * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
184
     */
185

  
186
/**
187
 * 
188
 * 
189
 * 
190
 * @param e 
191
 */
192
    public void windowOpened(WindowEvent e) {        
193
        // TODO Auto-generated method stub
194
    } 
195
 }
0 196

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/ui/showresults/ShowResultsDialogPanel.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.gazetteer.ui.showresults;
43
import java.awt.event.ActionEvent;
44
import java.awt.event.ActionListener;
45

  
46
import javax.swing.JButton;
47
import javax.swing.JDialog;
48
import javax.swing.JPanel;
49

  
50
import org.gvsig.gazetteer.GazetteerClient;
51
import org.gvsig.gazetteer.querys.Feature;
52
import org.gvsig.gazetteer.querys.GazetteerQuery;
53

  
54

  
55
/**
56
 * 
57
 * 
58
 * 
59
 * @author Jorge Piera Llodra (piera_jor@gva.es)
60
 */
61
public class ShowResultsDialogPanel extends JPanel implements ActionListener {
62
	private JDialog parent;
63
	protected ShowResultsPanel ppalPanel = null;
64
	protected GazetteerClient client = null;
65
	private int currentPage = 0;
66
	private int recordsByPage = 0;
67
	private JButton nextButton = null;
68
	private JButton lastButton = null;
69
	private JButton mapButton = null;
70
	private JButton closeButton = null;
71
	private int featuresLength = 0;
72
	protected GazetteerQuery query = null;
73

  
74
	/**
75
	 * @param client 
76
	 * @param features 
77
	 * @param recordsByPage 
78
	 * @param translator 
79
	 */
80
	public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, GazetteerQuery query) {        
81
		this.client = client;
82
		this.currentPage = 1;
83
		this.recordsByPage = recordsByPage;
84
		this.query = query;
85
		initialize(client,features,recordsByPage);     
86
	} 
87

  
88
	/**
89
	 * 
90
	 * 
91
	 * 
92
	 * @param client 
93
	 * @param features 
94
	 * @param recordsByPage 
95
	 */
96
	public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) {        
97
		this.featuresLength = features.length;
98
		this.currentPage = 1;
99
		this.recordsByPage = recordsByPage;
100
		ppalPanel = new ShowResultsPanel(features,getNumPages(),recordsByPage);
101
		setDefaultButtonListeners();
102

  
103
		add(ppalPanel);
104
	} 
105

  
106
	/**
107
	 * 
108
	 * 
109
	 */
110
	private void setDefaultButtonListeners() {        
111
		nextButton = ppalPanel.getNextButton();
112
		lastButton = ppalPanel.getLastButton();
113
		mapButton = ppalPanel.getMapButton();
114
		closeButton = ppalPanel.getCloseButton();
115

  
116
		nextButton.addActionListener(this);
117
		lastButton.addActionListener(this);
118
		mapButton.addActionListener(this);
119
		closeButton.addActionListener(this);
120
	} 
121

  
122
	/**
123
	 * 
124
	 * 
125
	 * 
126
	 * @param e 
127
	 */
128
	public void actionPerformed(ActionEvent e) {        
129
		if (e.getActionCommand().equals("next")) {
130
			nextButtonActionPerformed();
131
		} 
132
		if (e.getActionCommand().equals("last")) {
133
			lastButtonActionPerformed();
134
		} 
135
		if (e.getActionCommand().equals("localize")) {
136
			loadButtonActionPerformed();
137
		} 
138
		if (e.getActionCommand().equals("close")) {
139
			closeButtonActionPerformed();
140
		}
141

  
142
	} 
143

  
144
	/**
145
	 * 
146
	 * 
147
	 * 
148
	 * @return 
149
	 */
150
	private int getNumPages() {        
151
		if ((featuresLength % recordsByPage) == 0)
152
			return featuresLength/recordsByPage;
153
		return (featuresLength/recordsByPage) + 1;
154
	} 
155

  
156
	/**
157
	 * 
158
	 * 
159
	 */
160
	public void nextButtonActionPerformed() {        
161
		this.currentPage = this.currentPage + 1;
162

  
163
		if (this.currentPage == getNumPages()) {
164
			nextButton.setEnabled(false);
165
		} else {
166
			nextButton.setEnabled(true);
167
		}
168
		lastButton.setEnabled(true);
169
		ppalPanel.actualizaLabel(currentPage,recordsByPage);
170

  
171

  
172
	} 
173

  
174
	/**
175
	 * 
176
	 * 
177
	 */
178
	public void lastButtonActionPerformed() {        
179
		this.currentPage = this.currentPage - 1;
180
		if (this.currentPage == 1) {
181
			lastButton.setEnabled(false);
182
		} else {
183
			lastButton.setEnabled(true);
184
		}
185
		nextButton.setEnabled(true);
186

  
187
		ppalPanel.actualizaLabel(currentPage,recordsByPage);
188

  
189

  
190
	} 
191

  
192
	/**
193
	 * 
194
	 * 
195
	 */
196
	public void loadButtonActionPerformed() {        
197
		Feature feature = ppalPanel.getFeature();
198

  
199
		if (feature != null){
200
			System.out.println("ID: " + feature.getId());
201
			System.out.println("NAME: " + feature.getName());
202
			System.out.println("DESCRIPTION: " + feature.getDescription());
203
			System.out.println("COORDINATES: X=" + feature.getCoordinates().getX() + " Y=" + feature.getCoordinates().getY());
204
		}
205
	} 
206

  
207
	/**
208
	 * 
209
	 * 
210
	 */
211
	public void closeButtonActionPerformed() {        
212
		parent.setVisible(false);
213
	} 
214

  
215
	/**
216
	 * 
217
	 * 
218
	 * 
219
	 * @param parent The parent to set.
220
	 */
221
	public void setParent(JDialog parent) {        
222
		this.parent = parent;
223
	} 
224
}
0 225

  
tags/v2_0_0_Build_2038/applications/appGazetteer/appGazetteer/src/org/gvsig/gazetteer/ui/showresults/ShowResultsPanel.java
1

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

  
46
import javax.swing.BoxLayout;
47
import javax.swing.DefaultListModel;
48
import javax.swing.JButton;
49
import javax.swing.JLabel;
50
import javax.swing.JList;
51
import javax.swing.JPanel;
52
import javax.swing.JScrollPane;
53

  
54
import org.gvsig.gazetteer.querys.Feature;
55
import org.gvsig.i18n.Messages;
56

  
57

  
58
/**
59
 * 
60
 * 
61
 * 
62
 * @author Jorge Piera Llodra (piera_jor@gva.es)
63
 */
64
public class ShowResultsPanel extends JPanel {
65
/**
66
 * <p></p>
67
 * 
68
 * 
69
 * 
70
 * @poseidon-type es.gva.cit.gazetteer.querys.Feature
71
 */
72
    public java.util.Collection features = new java.util.ArrayList();
73
/**
74
 * 
75
 * 
76
 */
77
    private JPanel descriptionPanel = null;
78
/**
79
 * 
80
 * 
81
 */
82
    private JPanel linksPanel = null;
83
/**
84
 * 
85
 * 
86
 */
87
    private JButton mapButton = null;
88
//  @jve:decl-index=0:
89
/**
90
 * 
91
 * 
92
 */
93
    private JScrollPane descriptionScroll = null;
94
//  @jve:decl-index=0:
95
/**
96
 * 
97
 * 
98
 */
99
    private JLabel jLabel1 = null;
100
/**
101
 * 
102
 * 
103
 */
104
    private JPanel nextLastPanel = null;
105
/**
106
 * 
107
 * 
108
 */
109
    private JButton lastButton = null;
110
/**
111
 * 
112
 * 
113
 */
114
    private JLabel textLabel = null;
115
/**
116
 * 
117
 * 
118
 */
119
    private JButton nextButton = null;
120

  
121
/**
122
 * 
123
 * 
124
 */
125
    private int numPages;
126
/**
127
 * 
128
 * 
129
 */
130
    private JButton closeButton = null;
131
/**
132
 * 
133
 * 
134
 */
135
    private DefaultListModel listModel = null;
136
/**
137
 * 
138
 * 
139
 */
140
    private JList descriptionList = null;
141

  
142
/**
143
 * 
144
 * 
145
 * 
146
 * @param features 
147
 * @param numPages 
148
 * @param recordsByPage 
149
 * @param translator 
150
 */
151
    public  ShowResultsPanel(Feature[] features, int numPages, int recordsByPage) {        
152
        super();   
153
        setFeatures(features);
154
        this.numPages = numPages;
155
        initialize(recordsByPage);
156
    } 
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff