Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCatalogAndGazetteer / src / es / gva / cit / gvsig / catalog / gui / SearchDialog.java @ 15557

History | View | Annotate | Download (5.24 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.catalog.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.catalog.CatalogClient;
60
import es.gva.cit.catalog.drivers.GetRecordsReply;
61
import es.gva.cit.catalog.querys.Coordinates;
62
import es.gva.cit.catalog.ui.search.SearchDialogPanel;
63
import es.gva.cit.catalog.utils.Frames;
64

    
65
/**
66
 * This class is used to search a record using the catalog client
67
 * @author luisw
68
 * @modified by Jorge Piera
69
 */
70
public class SearchDialog extends SearchDialogPanel implements
71
IWindow,ViewPortListener {    
72
        public WindowInfo m_windowInfo = null;
73
        public ConnectDialog parentDialog = null;
74
        public JDialog frame = null;
75

    
76
        public SearchDialog(CatalogClient client, Object serverConnectFrame) {
77
                super(client,serverConnectFrame);
78
                parentDialog = (ConnectDialog)serverConnectFrame;
79
                setViewChangeListener();                
80
                loadViewPortCoordinates();
81
        }
82

    
83
        /* (non-Javadoc)
84
         * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
85
         */
86
        public WindowInfo getWindowInfo() {
87
                if (m_windowInfo == null){
88
                        m_windowInfo = new WindowInfo(WindowInfo.PALETTE);
89
                        m_windowInfo.setTitle(Messages.getText("gazetteer_search") + " [" +
90
                                        getCurrentServer() + "]");                
91
                        m_windowInfo.setHeight(80);
92
                        m_windowInfo.setWidth(525);
93
                }
94
                return m_windowInfo;
95

    
96
        }
97

    
98
        protected void showResultsActionPerformed(GetRecordsReply recordsReply) {
99
                JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false);
100
                Frames.centerFrame(panel,620,420);
101
                panel.setTitle(Messages.getText( "search_results")); 
102
                panel.setResizable(false);
103
                ShowResultsDialog dialog = new ShowResultsDialog(panel,
104
                                client,
105
                                recordsReply,
106
                                1);
107
                panel.getContentPane().add(dialog);
108
                panel.setVisible(true); 
109
        }
110

    
111
        protected void closeButtonActionPerformed() {
112
                closeJDialog();
113
        }
114

    
115
        /**
116
         * Size button action performed
117
         */         
118
        protected void resizeButtonActionPerformed(){
119
                if (isMinimized){
120
                        frame.setSize(frame.getWidth(),495);
121
                        getLowerPanel().setVisible(true);
122
                        getUpperPanel().setUpIcon();
123
                }else{
124
                        frame.setSize(frame.getWidth(),165);
125
                        getLowerPanel().setVisible(false);                                 
126
                        getUpperPanel().setDownIcon();
127
                }
128
                isMinimized = !isMinimized;
129
        }
130
        /**
131
         * Return button action
132
         */
133
        protected void lastButtonActionPerformed() {  
134
                closeJDialog();
135
                ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame;
136
                serverConnect.setVisible(true);
137
                serverConnect.getControlsPanel().enableSearchButton(false);
138
                PluginServices.getMDIManager().addWindow(serverConnect);
139
        } 
140

    
141
        public void closeJDialog() {
142
                frame.setVisible(false);
143
        }
144

    
145
        /**
146
         * This method loads the view coordinates to the catalog search dialog
147
         *
148
         */
149
        private void loadViewPortCoordinates(){
150
                BaseView activeView = 
151
                        (BaseView) PluginServices.getMDIManager().getActiveWindow();
152

    
153
                Rectangle2D r2d= activeView.getMapControl().getViewPort().getExtent();
154

    
155
                try{
156
                        getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
157
                                        r2d.getMaxY(),
158
                                        r2d.getMaxX(),
159
                                        r2d.getMinY()));
160
                }catch(NullPointerException E){
161
                        //We cant retrieve the coordinates if it doesn't 
162
                        //exist a loaded layer
163
                }
164
        }
165
        /*
166
         * This method joins the viewPort event to the listener
167
         */
168
        private void setViewChangeListener(){
169
                BaseView activeView = 
170
                        (BaseView) PluginServices.getMDIManager().getActiveWindow();
171

    
172
                activeView.getMapControl().getViewPort().addViewPortListener(this);
173

    
174
        }
175

    
176
        public void extentChanged(ExtentEvent e) {
177
                loadViewPortCoordinates();   
178

    
179
        }
180

    
181
        public void backColorChanged(ColorEvent e) {
182
                // TODO Auto-generated method stub
183

    
184
        }
185

    
186
        public void projectionChanged(ProjectionEvent e) {
187
                loadViewPortCoordinates();                
188
        }
189

    
190
        public void setFrame(JDialog frame) {
191
                this.frame = frame;
192
        }                      
193
}