svn-gvsig-desktop / branches / CatalogYNomenclator_v1_1_0_1005 / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / gui / SearchDialog.java @ 12754
History | View | Annotate | Download (5.35 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. 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 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package es.gva.cit.gvsig.catalogClient.gui; |
42 |
|
43 |
import java.awt.Frame; |
44 |
import java.awt.geom.Rectangle2D; |
45 |
|
46 |
import javax.swing.JDialog; |
47 |
|
48 |
import org.gvsig.i18n.Messages; |
49 |
|
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.andami.ui.mdiManager.IWindow; |
52 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
53 |
import com.iver.cit.gvsig.fmap.ColorEvent; |
54 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
55 |
import com.iver.cit.gvsig.fmap.ProjectionEvent; |
56 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
57 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
58 |
|
59 |
import es.gva.cit.catalogClient.CatalogClient; |
60 |
import es.gva.cit.catalogClient.drivers.GetRecordsReply; |
61 |
import es.gva.cit.catalogClient.querys.Coordinates; |
62 |
import es.gva.cit.catalogClient.schemas.records.Record; |
63 |
import es.gva.cit.catalogClient.ui.search.SearchDialogPanel; |
64 |
import es.gva.cit.catalogClient.utils.Frames; |
65 |
|
66 |
/**
|
67 |
* This class is used to search a record using the catalog client
|
68 |
* @author luisw
|
69 |
* @modified by Jorge Piera
|
70 |
*/
|
71 |
public class SearchDialog extends SearchDialogPanel implements |
72 |
IWindow,ViewPortListener { |
73 |
public WindowInfo m_windowInfo = null; |
74 |
public ConnectDialog parentDialog = null; |
75 |
public JDialog frame = null; |
76 |
|
77 |
public SearchDialog(CatalogClient client, Object serverConnectFrame) { |
78 |
super(client,serverConnectFrame);
|
79 |
parentDialog = (ConnectDialog)serverConnectFrame; |
80 |
setViewChangeListener(); |
81 |
loadViewPortCoordinates(); |
82 |
} |
83 |
|
84 |
/* (non-Javadoc)
|
85 |
* @see com.iver.andami.ui.mdiManager.View#getViewInfo()
|
86 |
*/
|
87 |
public WindowInfo getWindowInfo() {
|
88 |
if (m_windowInfo == null){ |
89 |
m_windowInfo = new WindowInfo(WindowInfo.PALETTE);
|
90 |
m_windowInfo.setTitle(Messages.getText("gazetteer_search") + " [" + |
91 |
getCurrentServer() + "]");
|
92 |
m_windowInfo.setHeight(80);
|
93 |
m_windowInfo.setWidth(525);
|
94 |
} |
95 |
return m_windowInfo;
|
96 |
|
97 |
} |
98 |
|
99 |
protected void showResultsActionPerformed(GetRecordsReply recordsReply) { |
100 |
JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false); |
101 |
Frames.centerFrame(panel,420,258); |
102 |
panel.setTitle(Messages.getText( "gazetteer_search"));
|
103 |
panel.setResizable(false);
|
104 |
|
105 |
ShowResultsDialog dialog = new ShowResultsDialog(panel,
|
106 |
client, |
107 |
recordsReply, |
108 |
10);
|
109 |
|
110 |
panel.getContentPane().add(dialog); |
111 |
panel.setVisible(true);
|
112 |
} |
113 |
|
114 |
protected void closeButtonActionPerformed() { |
115 |
closeJDialog(); |
116 |
} |
117 |
|
118 |
/**
|
119 |
* Size button action performed
|
120 |
*/
|
121 |
protected void resizeButtonActionPerformed(){ |
122 |
if (isMinimized){
|
123 |
frame.setSize(frame.getWidth(),495);
|
124 |
getLowerPanel().setVisible(true);
|
125 |
getUpperPanel().setUpIcon(); |
126 |
}else{
|
127 |
frame.setSize(frame.getWidth(),165);
|
128 |
getLowerPanel().setVisible(false);
|
129 |
getUpperPanel().setDownIcon(); |
130 |
} |
131 |
isMinimized = !isMinimized; |
132 |
} |
133 |
/**
|
134 |
* Return button action
|
135 |
*/
|
136 |
protected void lastButtonActionPerformed() { |
137 |
closeJDialog(); |
138 |
ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame; |
139 |
serverConnect.setVisible(true);
|
140 |
serverConnect.getControlsPanel().enableSearchButton(false);
|
141 |
PluginServices.getMDIManager().addWindow(serverConnect); |
142 |
} |
143 |
|
144 |
public void closeJDialog() { |
145 |
frame.setVisible(false);
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* This method loads the view coordinates to the catalog search dialog
|
150 |
*
|
151 |
*/
|
152 |
private void loadViewPortCoordinates(){ |
153 |
BaseView activeView = |
154 |
(BaseView) PluginServices.getMDIManager().getActiveWindow(); |
155 |
|
156 |
Rectangle2D r2d= activeView.getMapControl().getViewPort().getExtent();
|
157 |
|
158 |
try{
|
159 |
getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
|
160 |
r2d.getMaxY(), |
161 |
r2d.getMaxX(), |
162 |
r2d.getMinY())); |
163 |
}catch(NullPointerException E){ |
164 |
//We cant retrieve the coordinates if it doesn't
|
165 |
//exist a loaded layer
|
166 |
} |
167 |
} |
168 |
/*
|
169 |
* This method joins the viewPort event to the listener
|
170 |
*/
|
171 |
private void setViewChangeListener(){ |
172 |
BaseView activeView = |
173 |
(BaseView) PluginServices.getMDIManager().getActiveWindow(); |
174 |
|
175 |
activeView.getMapControl().getViewPort().addViewPortListener(this);
|
176 |
|
177 |
} |
178 |
|
179 |
public void extentChanged(ExtentEvent e) { |
180 |
loadViewPortCoordinates(); |
181 |
|
182 |
} |
183 |
|
184 |
public void backColorChanged(ColorEvent e) { |
185 |
// TODO Auto-generated method stub
|
186 |
|
187 |
} |
188 |
|
189 |
public void projectionChanged(ProjectionEvent e) { |
190 |
loadViewPortCoordinates(); |
191 |
} |
192 |
|
193 |
public void setFrame(JDialog frame) { |
194 |
this.frame = frame;
|
195 |
} |
196 |
} |